搜尋套件、儲存庫與 APP 分類

套件詳情v3.17.0

flutter_voximplant

Voximplant 插件,用於將語音和視訊通訊嵌入到 Flutter 應用程式中。

AndroidiOS
近 30 天下載
3270
喜歡數
35
Pub 分數
140

安裝套件

flutter pub add flutter_voximplant

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

flutter_voximplant 套件可實現即時語音與視訊通訊無縫整合至 Flutter 應用程式中。由 Voximplant 開發,提供簡單介面,用於建立點對點通話、管理音訊與影像串流,以及處理通話事件。此外掛支援 Android 與 iOS 平台,非常適合需要即時通訊功能的跨平台應用。它利用 Voximplant 雲端基礎設施,確保穩定連線與高品質媒體傳輸。開發者可藉此輕鬆建構遠距醫療、客戶服務或虛擬會議應用。該套件為開源並持續維護。

適用情境

  • 應用內視訊通話
  • 客戶服務聊天應用
  • 遠程醫療平台
  • 虛擬課堂
  • 遠端協作工具

主要特色

  • 即時語音和視頻通話
  • 跨平台支援(Android 與 iOS)
  • 與Voximplant雲的輕鬆整合
  • 媒體流管理
  • 呼叫事件處理

適合對象

  • 開發即時通訊應用的開發者
  • 需要快速VoIP整合的初創企業
  • 需要安全點對點通話的應用程式
  • 使用 Voximplant 後端服務的團隊

使用建議

  • 需要Voximplant帳戶和API金鑰
  • 依賴穩定的互聯網連接
  • 可能需要原生SDK設定以啟用進階功能
  • 受限於Voximplant的基礎設施

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

flutter_voximplant

Voximplant Flutter SDK for embedding voice and video communication into Flutter applications.

Supported platforms

Platform Minimum version
Android 5.0 (API 21)
iOS 12.0

Requirements

  • Flutter >= 3.24.0
  • Dart SDK ^3.5.0
  • Android: JDK 17, Android Gradle Plugin and Kotlin versions that support compileSdk 35 (AGP 8.6+, Kotlin 2.x are recommended)
  • iOS: Xcode 15+, Swift 5.9+

Installation

Add the dependency to your application's pubspec.yaml:

dependencies:
  flutter_voximplant: ^3.17.0

Then run:

flutter pub get
iOS setup
Info.plist

Add NSMicrophoneUsageDescription and NSCameraUsageDescription entries to your application's Info.plist:

<key>NSMicrophoneUsageDescription</key>
<string>Microphone is required to make audio calls</string>
<key>NSCameraUsageDescription</key>
<string>Camera is required to make video calls</string>
Android setup

It is required to add Java 11 support in android/app/build.gradle:

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
}

Usage

To get started, you'll need to register a free Voximplant developer account.

Initialization

Client is the main class of the SDK that provides access to Voximplant’s functions, the Voximplant().getClient() method is used to get its instance:

import 'package:flutter_voximplant/flutter_voximplant.dart';


VIClient client = Voximplant().getClient();
Connect and log in to the Voximplant Cloud

The VIClient.getClientState() method is used to get the current state of connection to the Voximplant cloud and perform the actions according to it.

When initializing and connecting the SDK to the Voximplant cloud, you need to specify the node to connect to. Your node is bound to your Voximplant account. To find which node your account belongs to, log in to your control panel and see the Credentials for working with API, SDK, SIP section on the main dashboard.

  const accountNode = VINode.NodeX;
  Future<String> loginWithPassword(String username, String password) async {
    VIClientState clientState = await _client.getClientState();
    if (clientState == VIClientState.LoggedIn) {
      return _displayName;
    }
    if (clientState == VIClientState.Disconnected) {
      await _client.connect(node: accountNode);
    }
    VIAuthResult authResult = await _client.login(username, password);
    _displayName = authResult.displayName;
    return _displayName;
  }
Make calls

To initiate a call we need the VIClient.call method. There is a VICallSettings class which could contain custom data and extra headers (SIP headers).

Since the call can behave in different ways, there is a group of call events. They can be triggered by the VICall class instance as the class contains all the functionality for call management.

  Future<VICall> makeAudioCall(String number) async {
     VICall call = await _client.call(number);
     call.onCallDisconnected = _onCallDisconnected;
     call.onCallFailed = _onCallFailed;
     call.onCallConnected = _onCallConnected;
     call.onCallRinging = _onCallRinging;
     call.onCallAudioStarted = _onCallAudioStarted;
     return call;
  }
   
  _onCallConnected(VICall call, Map<String, String>? headers) {
      print('Call connected');
  }
Receiving calls

Client.onIncomingCall is used to get incoming calls.

There are three methods for an incoming call: answer, decline and reject. An audio stream can be sent only after the answer method call.

  CallService._() {
    _client = Voximplant().getClient();
    _client.onIncomingCall = _onIncomingCall;
  }

  _onIncomingCall(VIClient client, VICall call, bool video, Map<String, String>? headers) async {
    await call.answer();
  }
Mid-call operations

Audio call can be put on/off hold

  _hold() async {
    try {
      await _call.hold(!_isOnHold);
      setState(() {
        _isOnHold = !_isOnHold;
      });
    } catch (e) {
      
    }

  }
Audio device management

VIAudioDeviceManager class API allow to:

  • get all available audio devices
  • get currently selected audio device
  • select audio device
  • handle active audio device changes and new audio devices (for example, Bluetooth headset or wired headset connection). These changes trigger the appropriate events.

All types of audio devices are represented in the VIAudioDevice enum.

Note that there are platform specific nuances in audio device management.

To select an audio device:

  _selectAudioDevice(VIAudioDevice device) async{
    VIAudioDeviceManager audioDeviceManager = Voximplant().getAudioDeviceManager();
    audioDeviceManager.onAudioDeviceChanged = _onAudioDeviceChange;
    await audioDeviceManager.selectAudioDevice(device);
  }

  _onAudioDeviceChange(VIAudioDeviceManager audioDeviceManager, AudioDevice audioDevice) {
    // audio device is changed
  }

Demo

https://github.com/voximplant/flutter_demos

Example

A sample application is available in example/. To run it:

cd example
flutter pub get
flutter run

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。