예제 #1
0
        public bool TogglePlay()
        {
            stateChangeQueue.DispatchSync(() => {
                if (isPlaying)
                {
                    player.Stop();
                    engine.Stop();
                    isPlaying = false;

                    SetSessionActive(false);
                }
                else
                {
                    SetSessionActive(true);

                    ScheduleLoop();
                    ScheduleLoop();

                    NSError error;
                    if (!engine.StartAndReturnError(out error))
                    {
                        Console.WriteLine(error.LocalizedDescription);
                    }

                    player.Play();
                    isPlaying = true;
                }
            });

            return(isPlaying);
        }
예제 #2
0
 public void Stop()
 {
     if (IsPlaying)
     {
         ForceStop = true;
         PlayerNode.Reset();
         PlayerNode.Stop();
     }
 }
예제 #3
0
    public void stop()
    {
        if (!running)
        {
            return;
        }

        running = false;

        AVAudioSession.SharedInstance().SetActive(false);

        if (audioPlayer != null)
        {
            try
            {
                audioPlayer.Stop();
                audioPlayer.Reset();
            }
            catch (Exception)
            {
            }

            audioPlayer.Dispose();
            audioPlayer = null;
        }

        if (audioDecoder != null)
        {
            audioDecoder.stop();
            audioDecoder.Dispose();
            audioDecoder = null;
        }

        if (audioEngine != null)
        {
            try
            {
                audioEngine.Stop();
                audioEngine.Reset();
            }
            catch (Exception)
            {
            }

            audioEngine.Dispose();
            audioEngine = null;
        }
    }
예제 #4
0
        void DeletePlayer()
        {
            Stop();

            if (player != null && player.Playing)
            {
                player.Stop();
            }

            if (engine != null && engine.Running)
            {
                engine.Stop();
            }

            if (player != null && engine != null && pitch != null)
            {
                engine.Dispose();
                player.Dispose();
                pitch.Dispose();
                engine = null;
                player = null;
                pitch  = null;
            }
        }