public void Stop() { if (m_pSession != null) { HResult hr = m_pSession.Stop(); } }
/// <summary> /// Stops the media, but does not VerifyAccess() on /// the Dispatcher. This can be used by destructors /// because it happens on another thread and our /// DirectShow graph and COM run in MTA /// </summary> protected void StopInternal() { if (m_pSession != null) { m_pSession.Stop(); } }
//////////////////////////////////////////////////////////////////////////////////////// // Name: CPlayer::Stop (Public) // Description: // Stops the media session with the current topology /////////////////////////////////////////////////////////////////////////////////////////// public HResult Stop() { Debug.WriteLine("CPlayer::Stop"); HResult hr = 0; try { hr = m_pMediaSession.Stop(); MFError.ThrowExceptionForHR(hr); } catch (Exception e) { hr = (HResult)Marshal.GetHRForException(e); } return(hr); }
/// <summary> /// Stops playback /// </summary> public void Stop() { if (!IsPrepared) { throw new InvalidOperationException("This player is still loading."); } if (State != PlaybackState.Playing) { throw new InvalidOperationException("The player isn't playing"); } m_Session.Stop(); }
public void Stop() { if (m_Session == null) { throw new InvalidOperationException("This player hasn't initialized yet"); } if (!Prepared) { throw new InvalidOperationException("This player is still loading."); } m_Session.Stop(); PlaybackState = PlaybackState.Stopped; PlaybackStopped?.Invoke(this, new StoppedEventArgs()); }
private static HResult RunMediaSession(IMFMediaSession mediaSession) { HResult hr = S_OK; bool receiveSessionEvent = true; while (receiveSessionEvent) { HResult hrStatus = S_OK; IMFMediaEvent mediaEvent = null; MediaEventType eventType = MediaEventType.MEUnknown; MFTopoStatus topoStatus = MFTopoStatus.Invalid; hr = mediaSession.GetEvent(MFEventFlag.None, out mediaEvent); if (Succeeded(hr)) { hr = mediaEvent.GetStatus(out hrStatus); } if (Succeeded(hr)) { hr = mediaEvent.GetType(out eventType); } if (Succeeded(hr) && Succeeded(hrStatus)) { switch (eventType) { case MediaEventType.MESessionTopologySet: Debug.WriteLine("MediaSession:TopologySetEvent"); break; case MediaEventType.MESessionTopologyStatus: Debug.WriteLine("MediaSession:TopologStatusEvent"); hr = mediaEvent.GetUINT32(MF_EVENT_TOPOLOGY_STATUS, out int topoStatusInt); if (Succeeded(hr)) { topoStatus = (MFTopoStatus)topoStatusInt; switch (topoStatus) { case MFTopoStatus.Ready: Debug.WriteLine("MediaSession:TopologyStatus: MFTopoStatus.Ready"); hr = mediaSession.Start(); break; default: Debug.WriteLine("MediaSession:TopologyStatus: MFTopoStatus." + topoStatus); break; } } break; case MediaEventType.MESessionClosed: Debug.WriteLine("MediaSession:SessionClosedEvent"); receiveSessionEvent = false; break; case MediaEventType.MESessionStopped: Debug.WriteLine("MediaSession:SesssionStoppedEvent"); hr = mediaSession.Stop(); break; default: Debug.WriteLine("MediaSession:Event: " + eventType); break; } mediaEvent = null; if (Failed(hr) || Failed(hrStatus)) { receiveSessionEvent = false; } } } return(hr); }