//EventHandler for showing local video in ui private void Peer_LocalI420FrameReady(I420AVideoFrame frame) { lock (localVideoLock) { if (!localVideoPlaying) { localVideoPlaying = true; // Capture the resolution into local variable useable from the lambda below uint width = frame.width; uint height = frame.height; // Defer UI-related work to the main UI thread RunOnMainThread(() => { // Bridge the local video track with the local media player UI int framerate = 30; // for lack of an actual value localVideoSource = CreateI420VideoStreamSource(width, height, framerate); var localVideoPlayer = new MediaPlayer(); localVideoPlayer.Source = MediaSource.CreateFromMediaStreamSource(localVideoSource); Mpe_localVideo.SetMediaPlayer(localVideoPlayer); localVideoPlayer.Play(); }); } } localVideoBridge.HandleIncomingVideoFrame(frame); }
//Suspending-EventHandler of app: executes when app turns into suspending-state private void App_Suspending(object sender, SuspendingEventArgs e) { if (peerConnection != null) { //Closing of PeerConnection peerConnection.Close(); //Disposing of PeerConnection-Resources peerConnection.Dispose(); peerConnection = null; Debugger.Log(0, "", "Peer conection disposed successfully\n"); } //Disposing of MediaPlayers Mpe_localVideo.SetMediaPlayer(null); Mpe_remoteVideo.SetMediaPlayer(null); //Disposing of signaler if (signaler != null) { signaler.StopPollingAsync(); signaler = null; } }