ant_media_flutter 套件可跨 Android、iOS、Web 與桌面平台,使用 Ant Media Server 企業版實現即時串流與通訊。它提供一個適合 Flutter 的介面,用於整合基於 WebRTC 的即時音視頻串流,支援低延遲傳輸,非常適合互動式應用。該套件利用 Ant Media Server 強大的基礎架構,提供可擴展、安全且高效能的串流解決方案。開發者可輕鬆建構即時廣播、視訊會議與互動媒體應用。完整原始碼皆可於 GitHub 上取得,確保透明度與客製化。
適用情境
直播視頻廣播
視訊會議
互動網路研討會
即時遊戲串流
遠程教育平台
主要特色
跨平台 WebRTC 支援
低延遲串流
安全連接協議
可擴展的伺服器整合
輕鬆整合 Flutter
適合對象
開發即時影片應用的開發者
使用 Ant Media Server 的團隊
需要多平台串流的專案
需要低延遲通訊的應用程式
教育或企業視頻解決方案
使用建議
需要 Ant Media Server 企業版
僅限支援的平台(Android、iOS、Web、桌面端)
伺服器設定需要完整功能
可能需要額外的網路設定以獲得最佳效能
依賴穩定的互聯網連接
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
This Flutter Package includes Ant Media Flutter SDK for WebRTC.
To be able to use it, you need to have an Ant Media Server instance first. To be able to get more information, you can check Ant Media Server's website.
If you have Ant Media Server Community Edition, you can only use WebRTC publishing feature.
WebRTC play, Conference and Data Channel features are available in Ant Media Server Enterprise Edition.
Connect is the main function that we can do pretty much everything with using its parameters. Let's look at its parts and how we can use it for different purposes like WebRTC Publishing, WebRTC Playing, etc.
Sections of the connect function
-> Host
Host is the websocket url of your Ant Media Server instance.
-> Stream ID
Stream ID is used to identify each stream for publishing and playing purposes.
-> Room ID
Room ID is used in the WebRTC Multi track Conference mode.
-> Type
Type is used to determine different modes. Possible options:
AntMediaType.Publish
AntMediaType.Play
AntMediaType.Peer
AntMediaType.Conference
AntMediaType.DataChannelOnly
-> User Screen
User Screen is used to switch between screen and camera publishing mode during initialization part.
-> On State Change
On State Change is the status of the websocket connection between Ant Media Server and the device which uses the SDK. Possible options:
HelperState.CallStateNew
HelperState.CallStateBye
HelperState.ConnectionOpen
HelperState.ConnectionClosed
HelperState.ConnectionError
-> On Local Stream
On Local Stream is triggered whenever we started sending stream to the Ant Media Server.
-> On Add Remote Stream
On Add Remote Stream is triggered whenever we receive a new remote stream from the Ant Media Server.
-> On Data Channel
On Data Channel is triggered when the data channel state changed.
-> On Data Channel Message
On Data Channel Message is triggered whenever we receive a new data channel message.
-> On Update Conference Person
On Update Conference Person is triggered whenever someone added/removed from the conference room on the fly.
-> On Remove Remote Stream
On Remove Remote Stream is triggered whenever you stopped publishing yourself or the stream that you are playing stopped publishing.
-> Ice Servers
Ice Servers is the list where you can define your own turn/stun server list.
-> Callbacks
Callbacks you can listen all the callbacks which are sent from the Ant Media Server side.
Gallery
Examples
Conference Sample App - An example of how to create a WebRTC Multi track Conference application using Ant Media Server Flutter SDK
Data Channel Sample App - An example of how to create a Data Channel text based messaging application using Ant Media Server Flutter SDK
Peer Sample App - An example of how to create a Peer to Peer application using Ant Media Server Flutter SDK
Play Sample App - An example of how to create a WebRTC Player using Ant Media Server Flutter SDK
Publish Sample App - An example of how to create a WebRTC Publish application using Ant Media Server Flutter SDK
Sample Project - It's a complete sample project which contains every sample above.
Function List
AntMediaFlutter.anthelper?.switchCamera()
You can call switchCamera() to switch between front and back camera on mobile devices.
AntMediaFlutter.anthelper?.muteMic(bool mute)
You can call muteMic(bool mute) to mute/unmute microphone.
AntMediaFlutter.anthelper?.toggleCam(bool state)
You can call toggleCam(bool state) to open/close your camera.
AntMediaFlutter.anthelper?.disconnectPeer()
You can call disconnectPeer() to stop a peer connection.
You can call registerPushNotificationToken(subscriberId, authToken, pushNotificationToken, tokenType) to register user push notification token to Ant Media Server.