/// <summary> /// Pause media /// </summary> /// <returns></returns> public int Pause() { TRACE("Media::Pause"); if (m_state != MediaState.Started) { return(E_Fail); } if (m_pSession == null || m_pSource == null) { return(E_Unexpected); } int hr = S_Ok; try { m_pSession.Pause(); m_state = MediaState.PausePending; NotifyState(); } catch (Exception e) { hr = Marshal.GetHRForException(e); NotifyError(hr); } return(hr); }
/// <summary> /// Pauses the media /// </summary> public virtual void Pause() { VerifyAccess(); if (m_pSession != null) { m_pSession.Pause(); } }
/// <summary> /// Pauses playback. /// </summary> public void Pause() { if (!IsPrepared) { throw new InvalidOperationException("This player is still loading."); } if (State != PlaybackState.Playing) { throw new InvalidOperationException("The player isn't playing"); } m_Session.Pause(); }
public void Pause() { 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.Pause(); PlaybackState = PlaybackState.Paused; }
//////////////////////////////////////////////////////////////////////////////////////// // Name: CPlayer::Pause (Public) // Description: // Pauses the media session with the current topology /////////////////////////////////////////////////////////////////////////////////////////// public HResult Pause() { Debug.WriteLine("\nCPlayer::Pause"); HResult hr = 0; try { // pause the media session. hr = m_pMediaSession.Pause(); MFError.ThrowExceptionForHR(hr); } catch (Exception e) { hr = (HResult)Marshal.GetHRForException(e); } return(hr); }
private void mPlayPauseBtn_Click(object sender, RoutedEventArgs e) { mIsSeek = false; mNewValue = -1.0; if (mIsPlaying) { HResult hr = m_pSession.Pause(); if (hr == HResult.S_OK) { mImageBtn.Source = new BitmapImage(new Uri("pack://application:,,,/WPFMediaFoundationPlayer;component/Images/play-button.png", UriKind.Absolute)); mIsPlaying = false; mTickTimer.Stop(); } } else { StartPlayback(); } }