public void initializeVideoPlayer(VideoPlayerViewModel videoPlayer) { if (IsInitialized == true) { return; } this.VideoPlayer = videoPlayer; videoPlayer.StateChanged += videoPlayer_StateChanged; videoPlayer.IsBufferingChanged += videoPlayer_IsBufferingChanged; videoPlayer.PositionSecondsChanged += videoPlayer_PositionSecondsChanged; videoPlayer.DurationSecondsChanged += videoPlayer_DurationSecondsChanged; videoPlayer.HasAudioChanged += videoPlayer_HasAudioChanged; videoPlayer.IsMutedChanged += videoPlayer_IsMutedChanged; videoPlayer.VolumeChanged += videoPlayer_VolumeChanged; MinVolume = videoPlayer.MinVolume; MaxVolume = videoPlayer.MaxVolume; videoPlayer.IsMuted = IsMuted; videoPlayer.Volume = Volume; videoPlayer.MinNrBufferedPackets = Settings.Default.VideoMinBufferedPackets; //VideoSettings.MaxNrBufferedPackets = videoPlayer.MaxNrBufferedPackets; IsInitialized = true; isInitializedSignal.Release(); }
protected virtual void Dispose(bool cleanupManaged) { if (IsInitialized == false) { return; } if (cleanupManaged) { // cleanup unmanaged if (VideoPlayer != null) { CloseCommand.Execute(); VideoPlayer.StateChanged -= videoPlayer_StateChanged; VideoPlayer.PositionSecondsChanged -= videoPlayer_PositionSecondsChanged; VideoPlayer.DurationSecondsChanged -= videoPlayer_DurationSecondsChanged; VideoPlayer.HasAudioChanged -= videoPlayer_HasAudioChanged; VideoPlayer.Dispose(); VideoPlayer = null; } IsInitialized = false; } }
public VideoRender() { //videoPlayerViewModel = new VideoPlayerViewModel(displayVideoFrame, VideoLib.VideoPlayer.DecodedVideoFormat.BGRA); videoPlayerViewModel = new VideoPlayerViewModel(displayVideoFrame, VideoLib.VideoPlayer.DecodedVideoFormat.YUV420P); videoPlayerViewModel.VideoOpened += new EventHandler(videoPanelViewModel_VideoOpened); videoPlayerViewModel.VideoClosed += new EventHandler(videoPanelViewModel_VideoClosed); yuvTexture = new Texture2D[3] { null, null, null }; textureView = new ShaderResourceView[3] { null, null, null }; nrTextures = 0; }