/// <summary> /// Set the video track used as the video source of the media player. /// </summary> /// <param name="videoTrack">The video track to use.</param> public void SetVideoTrack(VideoTrackViewModel videoTrack) { if (_playbackVideoTrack == videoTrack) { return; } // Notify media player that source changed if (_isVideoPlaying) { _videoStreamSource.NotifyError(MediaStreamSourceErrorStatus.ConnectionToServerLost); _videoPlayer.Pause(); _isVideoPlaying = false; } // Detach old source if (_playbackVideoTrack?.Track != null) { _playbackVideoTrack.Track.I420AVideoFrameReady -= VideoTrack_I420AFrameReady; _videoWidth = 0; _videoHeight = 0; _videoStatsTimer.Stop(); _videoBridge.Clear(); UpdateVideoStats(); ThreadHelper.RunOnMainThread(() => { RaisePropertyChanged("FrameWidth"); RaisePropertyChanged("FrameHeight"); }); } _playbackVideoTrack = videoTrack; // Attach new source if (_playbackVideoTrack?.Track != null) { _playbackVideoTrack.Track.I420AVideoFrameReady += VideoTrack_I420AFrameReady; _videoStatsTimer.Start(); } RaisePropertyChanged("VideoTrack"); }
/// <summary> /// Callback on remote video track removed. /// </summary> /// <param name="track">The video track removed.</param> private void OnRemoteVideoTrackRemoved(Transceiver transceiver, RemoteVideoTrack track) { Logger.Log($"Removed remote video track {track.Name} from transceiver {transceiver.Name}."); ThreadHelper.RunOnMainThread(() => { var vtvm = VideoTracks.Single(vm => vm.TrackImpl == track); VideoTracks.Remove(vtvm); }); //IVideoTrack newPlaybackVideoTrack = null; //if (LocalVideoTracks.Count > 0) //{ // newPlaybackVideoTrack = LocalVideoTracks[0].Track; //} //else //{ // videoTrackComboBox.IsEnabled = false; // _videoStatsTimer.Stop(); //} //SwitchMediaPlayerSource(_playbackAudioTrack, newPlaybackVideoTrack); }