Пример #1
0
            protected virtual void Dispose(bool disposing)
            {
                if (!disposedValue)
                {
                    if (disposing)
                    {
                        // TODO: dispose managed state (managed objects).
                    }

                    // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                    // TODO: set large fields to null.
#if __IOS__
                    m_audioTrack?.Stop();
                    m_audioTrack?.Dispose();
                    m_memory?.Dispose();
                    m_memory = null;
#elif __ANDROID__
                    m_audioTrack?.Stop();
                    m_audioTrack?.Flush();
                    m_audioTrack?.Release();
                    m_audioTrack?.Dispose();
#elif NETFX_CORE
                    m_audioTrack?.Pause();
                    m_memory?.Flush();
                    m_memory?.Dispose();
                    m_memory = null;
#endif
                    m_audioTrack  = null;
                    disposedValue = true;
                }
            }
Пример #2
0
        Task StopPlaying()
        {
            if (Player?.PlaybackSession?.CanPause == true)
            {
                Player?.Pause();
            }

            return(Task.CompletedTask);
        }
Пример #3
0
 //<SnippetRenderSoundLevelChanged>
 private void RenderAudioStateMonitor_SoundLevelChanged(AudioStateMonitor sender, object args)
 {
     if ((sender.SoundLevel == SoundLevel.Full) ||
         (sender.SoundLevel == SoundLevel.Low && !isPodcast))
     {
         mediaPlayer.Play();
     }
     else if ((sender.SoundLevel == SoundLevel.Muted) ||
              (sender.SoundLevel == SoundLevel.Low && isPodcast))
     {
         // Pause playback if we’re muted or if we’re playing a podcast and are ducked
         mediaPlayer.Pause();
     }
 }
        /// <summary>
        /// end the current cast session, and call CastEnd event
        /// </summary>
        /// <param name="sendEvent">should CastEnd be called?</param>
        void EndCurrentSession(bool sendEvent)
        {
            currentPlayer?.Pause();
            currentPlayer?.Dispose();
            currentPlayer = null;

            CurrentConnection?.Disconnect(MiracastReceiverDisconnectReason.Finished);
            CurrentConnection = null;

            currentSession?.Dispose();
            currentSession = null;

            if (sendEvent)
            {
                CastEnd?.Invoke();
            }
        }
Пример #5
0
            public async void Stop()
            {
                if (m_PlayThread != Unit.CompletedTask)
                {
                    try
                    {
                        cancellation.Cancel();
                        await m_PlayThread;
                    }
                    catch (Exception)
                    {
                    }
                }
                if (m_audioTrack != null)
                {
#if !WINDOWS_UWP
                    m_audioTrack.Stop();
                    m_audioTrack.Dispose();
#else
                    m_audioTrack.Pause();
#endif
                    m_audioTrack = null;
                }
            }