void TryPlayVideo() { // On some computers video playback can fail. In the moment we call m_videoPlayer.Play // So I try/catched it. Better no video than crashing game. try { if (m_videoPlayer != null) m_videoPlayer.Dispose(); // Start playback m_videoPlayer = new VideoPlayer(MyMinerGame.Static.RootDirectory + "\\" + m_currentVideo, MyMinerGame.Static.GraphicsDevice); m_videoPlayer.Play(); m_videoPlayer.Volume = m_volume * 2; } catch (Exception ex) { // Log this exception but then ignore it MyMwcLog.WriteLine(ex); // Because of this exception, video player must be invalidated. We don't know what it contains. // This will close this screen m_videoPlayer = null; } }
public override bool CloseScreen() { bool ret = base.CloseScreen(); if (ret) { if (m_videoPlayer != null) { m_videoPlayer.Stop(); m_videoPlayer.Dispose(); m_videoPlayer = null; } } return ret; }
public override void UnloadContent() { // Stop playback if (m_videoPlayer != null) { m_videoPlayer.Stop(); m_videoPlayer.Dispose(); m_videoPlayer = null; } m_currentVideo = ""; base.UnloadContent(); //This one causes leaks in D3D //GC.Collect(); }