-
Notifications
You must be signed in to change notification settings - Fork 4
Xamarin Forms WebRTC
CRITICAL thing about SDK It Does Not Support Any Simulator build for now. it's Xamarin issue, details here
WebRTC Native iOS SDK lets developers build their own native WebRTC applications that with just some clicks. WebRTC Android SDK has built-in functions such as publishing to Ant Media Server for one-to-many streaming, playing a stream in Ant Media Server and lastly P2P communication by using Ant Media Server as a signaling server. Anyway, no need to say too many things let's make our hands dirty.
WebRTC Native Android SDK and it's nuget package with bindings to Xamarin a free to use for Ant Media Server Enterprise users.
In this wiki, we're going to cover the following topics.
-
Develop a WebRTC Xamrin Forms app
- How to Play
- How to Publish
- preview before Publishing stream
- mute Audio
- mute Video
- switch Camera
-
Run the Sample WebRTC Forms app
- Play Stream on your iPhone or Android
- Publish Stream from your iPhone or Android
- preview before Publishing stream
- mute Audio
- mute Video
- switch Camera
- Detailed description of Custom Forms SDK classes
-
nuget package DT.Xamarin.AntMedia.WebRTC.Forms
-
to project Core - add nuget package DT.Xamarin.AntMedia.WebRTC.Forms
-
add
[assembly: ExportRenderer(typeof(AntWebRTCView), typeof(AntWebRTCViewRenderer))]
to AppDelegate.cs, outside of namespacesusing DT.Xamarin.AntMedia.WebRTC.Forms; using DT.Xamarin.AntMedia.WebRTC.Forms.iOS; using Foundation; using UIKit; using Xamarin.Forms; [assembly: ExportRenderer(typeof(AntWebRTCView), typeof(AntWebRTCViewRenderer))] namespace DT.WebRTC.Forms.iOS ...
-
add reference to framework on page or some view in Core project
xmlns:ant="clr-namespace:DT.Xamarin.AntMedia.WebRTC.Forms;assembly=DT.Xamarin.AntMedia.WebRTC.Forms"
and use special control
<ant:AntWebRTCView x:Name="AntFrame" Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="1" RenderingMode="ScaleAspectFit" WebRTCMode="Publish" Camera="Front" ShowDebugLogs="True" InitMode="InitOnViewRender" PlayStarted="AntFrame_Refresh" PlayFinished="AntFrame_Refresh" PublishStarted="AntFrame_Refresh" PublishFinished="AntFrame_Refresh" Error="AntFrame_Error" />
set server address and token(token can be empty string)
AntFrame.Server = InitialData.SERVER_URL; AntFrame.Token = InitialData.Token;
to Start or Stop stream call where you need
void SomeActionButton_Clicked(System.Object sender, System.EventArgs e) { if (AntFrame.IsPublishing || AntFrame.IsPlaying) { AntFrame.Stop(); DelayedRestart();//if publishing that will make rendering from camera to layout as preview } else { AntFrame.Start(); } }
-
to Create Forms Android and iOS app then you can use
What in Sample app
Simple copy of AntMedia sample app with all basic video call functions:
- Start/Stop Publishing WebRTC stream
- Start/Stop Playing WebRTC stream
- Init to preview from camera before start publishing
- Mute audio
- Mute video
- Switch camera