public override void Pause()
 {
     if (mSong != null && !mSong.IsDisposed)
     {
         mSong.Pause();
     }
 }
Exemple #2
0
 public void Pause()
 {
     lock (ControlLock)
     {
         _State = SoundState.Paused;
         Inst?.Pause();
     }
 }
Exemple #3
0
        public void Pause()
        {
            if (_isPlaying)
            {
                _playback.Pause();

                _isPlaying = false;
                _isPaused  = true;
            }
        }
Exemple #4
0
        public void Pause()
        {
            if (MediaState == MediaState.Paused)
            {
                return;
            }

            MediaState = MediaState.Paused;
            effect.Pause();
        }
Exemple #5
0
        public void Playback_Exceptions()
        {
            var instance = new DynamicSoundEffectInstance(16000, AudioChannels.Mono);

            instance.Dispose();
            Assert.Throws <ObjectDisposedException>(() => { instance.Play(); });
            Assert.Throws <ObjectDisposedException>(() => { instance.Pause(); });
            Assert.Throws <ObjectDisposedException>(() => { instance.Resume(); });
            Assert.Throws <ObjectDisposedException>(() => { instance.Stop(); });
            Assert.Throws <ObjectDisposedException>(() => { instance.Stop(false); });
            Assert.Throws <ObjectDisposedException>(() => { instance.SubmitBuffer(new byte[0]); });
        }
Exemple #6
0
        public void Playback()
        {
            using (var instance = new DynamicSoundEffectInstance(48000, AudioChannels.Mono))
            {
                // Initially, the playback is stopped
                Assert.AreEqual(SoundState.Stopped, instance.State);

                // Submitting a buffer will not change the state
                instance.SubmitBuffer(GenerateSineWave(440, 48000, 1, 0.5f));
                Assert.AreEqual(SoundState.Stopped, instance.State);

                // Start playing
                instance.Play();
                Assert.AreEqual(SoundState.Playing, instance.State);

                // While still playing, pause the playback
                SleepWhileDispatching(300);
                instance.Pause();
                Assert.AreEqual(SoundState.Paused, instance.State);

                // Let it continue and run out of buffers
                instance.Resume();
                SleepWhileDispatching(300);
                Assert.AreEqual(0, instance.PendingBufferCount);
                Assert.AreEqual(SoundState.Playing, instance.State);

                // Submit a buffer and the playback should continue
                instance.SubmitBuffer(GenerateSineWave(466, 48000, 1, 1.0f));
                Assert.AreEqual(SoundState.Playing, instance.State);
                SleepWhileDispatching(500);

                // Stop immediately
                Assert.AreEqual(SoundState.Playing, instance.State);
                instance.Stop();
                SleepWhileDispatching(10); // XNA does not stop it until FrameworkDispatcher.Update is called
                Assert.AreEqual(SoundState.Stopped, instance.State);

                // And then resume
                instance.Resume();
                Assert.AreEqual(SoundState.Playing, instance.State);
            }
        }
Exemple #7
0
        public void Pause()
        {
            checkDisposed();

            // Check the player state before attempting anything.
            if (State != MediaState.Playing)
            {
                return;
            }

            // Update the player state.
            State = MediaState.Paused;

            // Pause timer, audio.
            timer.Stop();
            if (audioStream != null)
            {
                audioStream.Pause();
            }
        }
        public void TestPlayableInterface()
        {
            WaveFormat dataFormat;
            using (var stream = AssetManager.FileProvider.OpenStream("EffectFishLamp", VirtualFileMode.Open, VirtualFileAccess.Read))
            {
                var memoryStream = new MemoryStream((int)stream.Length);
                stream.CopyTo(memoryStream);
                memoryStream.Position = 0;

                var waveStreamReader = new SoundStream(memoryStream);
                dataFormat = waveStreamReader.Format;
                bufferData = new byte[waveStreamReader.Length];

                if (waveStreamReader.Read(bufferData, 0, (int)waveStreamReader.Length) != waveStreamReader.Length)
                    throw new AudioSystemInternalException("The data length read in wave soundStream does not correspond to the stream's length.");
            }
            dynSEInstance = new DynamicSoundEffectInstance(defaultEngine, dataFormat.SampleRate, (AudioChannels)dataFormat.Channels, (AudioDataEncoding)dataFormat.BitsPerSample);
            dynSEInstance.BufferNeeded += SubmitBuffer;

            //////////////////
            // 1. Test play
            dynSEInstance.Play();
            Utilities.Sleep(2000);
            Assert.AreEqual(SoundPlayState.Playing, dynSEInstance.PlayState, "Music is not playing");

            //////////////////
            // 2. Test Pause
            dynSEInstance.Pause();
            Utilities.Sleep(600);
            Assert.AreEqual(SoundPlayState.Paused, dynSEInstance.PlayState, "Music is not Paused");
            dynSEInstance.Play();
            Utilities.Sleep(1000);

            //////////////////
            // 2. Test Stop
            dynSEInstance.Stop();
            bufferCount = 0;
            Utilities.Sleep(600);
            Assert.AreEqual(SoundPlayState.Stopped, dynSEInstance.PlayState, "Music is not Stopped");
            dynSEInstance.Play();
            Utilities.Sleep(9000);

            ///////////////////
            // 3. Test ExitLoop
            Assert.DoesNotThrow(dynSEInstance.ExitLoop, "ExitLoop crached");

            ///////////////
            // 4. Volume
            var value = 1f;
            var sign = -1f;
            while (value <= 1f)
            {
                dynSEInstance.Volume = value;

                value += sign * 0.01f;
                Utilities.Sleep(30);

                if (value < -0.2)
                    sign = 1f;
            }
            Utilities.Sleep(2000);

            //////////////////
            // 5.Pan
            value = 0;
            sign = -1f;
            while (value <= 1f)
            {
                dynSEInstance.Pan = value;

                value += sign * 0.01f;
                Utilities.Sleep(30);

                if (value < -1.2)
                    sign = 1f;
            }
            dynSEInstance.Pan = 0;
            Utilities.Sleep(2000);
            
            ////////////////////////////////////////////////////////////////////////////
            // 7. Wait until the end of the stream to check that there are not crashes
            Utilities.Sleep(50000);

            dynSEInstance.Dispose();
        }
Exemple #9
0
        public void TestPlayableInterface()
        {
            WaveFormat dataFormat;

            using (var stream = AssetManager.FileProvider.OpenStream("EffectFishLamp", VirtualFileMode.Open, VirtualFileAccess.Read))
            {
                var memoryStream = new MemoryStream((int)stream.Length);
                stream.CopyTo(memoryStream);
                memoryStream.Position = 0;

                var waveStreamReader = new SoundStream(memoryStream);
                dataFormat = waveStreamReader.Format;
                bufferData = new byte[waveStreamReader.Length];

                if (waveStreamReader.Read(bufferData, 0, (int)waveStreamReader.Length) != waveStreamReader.Length)
                {
                    throw new AudioSystemInternalException("The data length read in wave soundStream does not correspond to the stream's length.");
                }
            }
            dynSEInstance = new DynamicSoundEffectInstance(defaultEngine, dataFormat.SampleRate, (AudioChannels)dataFormat.Channels, (AudioDataEncoding)dataFormat.BitsPerSample);
            dynSEInstance.BufferNeeded += SubmitBuffer;

            //////////////////
            // 1. Test play
            dynSEInstance.Play();
            Utilities.Sleep(2000);
            Assert.AreEqual(SoundPlayState.Playing, dynSEInstance.PlayState, "Music is not playing");

            //////////////////
            // 2. Test Pause
            dynSEInstance.Pause();
            Utilities.Sleep(600);
            Assert.AreEqual(SoundPlayState.Paused, dynSEInstance.PlayState, "Music is not Paused");
            dynSEInstance.Play();
            Utilities.Sleep(1000);

            //////////////////
            // 2. Test Stop
            dynSEInstance.Stop();
            bufferCount = 0;
            Utilities.Sleep(600);
            Assert.AreEqual(SoundPlayState.Stopped, dynSEInstance.PlayState, "Music is not Stopped");
            dynSEInstance.Play();
            Utilities.Sleep(9000);

            ///////////////////
            // 3. Test ExitLoop
            Assert.DoesNotThrow(dynSEInstance.ExitLoop, "ExitLoop crached");

            ///////////////
            // 4. Volume
            var value = 1f;
            var sign  = -1f;

            while (value <= 1f)
            {
                dynSEInstance.Volume = value;

                value += sign * 0.01f;
                Utilities.Sleep(30);

                if (value < -0.2)
                {
                    sign = 1f;
                }
            }
            Utilities.Sleep(2000);

            //////////////////
            // 5.Pan
            value = 0;
            sign  = -1f;
            while (value <= 1f)
            {
                dynSEInstance.Pan = value;

                value += sign * 0.01f;
                Utilities.Sleep(30);

                if (value < -1.2)
                {
                    sign = 1f;
                }
            }
            dynSEInstance.Pan = 0;
            Utilities.Sleep(2000);

            ////////////////////////////////////////////////////////////////////////////
            // 7. Wait until the end of the stream to check that there are not crashes
            Utilities.Sleep(50000);

            dynSEInstance.Dispose();
        }
Exemple #10
0
 public void Pause()
 {
     _instance.Pause();
     //_iSaidStop = true;
 }
Exemple #11
0
 public void Pause()
 {
     lock (sound) {
         sound.Pause();
     }
 }
Exemple #12
0
        public void Start()
        {
            Stream = new Mp3Stream(Path);
            Stream.DecodeFrames(1);
            var freq = Stream.Frequency;

            lock (ControlLock)
            {
                if (Disposed)
                {
                    return;
                }
                Inst               = new DynamicSoundEffectInstance(freq, AudioChannels.Stereo);
                Inst.IsLooped      = false;
                Inst.BufferNeeded += SubmitBufferAsync;
                if (_State == SoundState.Playing)
                {
                    Inst.Play();
                }
                else if (_State == SoundState.Paused)
                {
                    Inst.Play();
                    Inst.Pause();
                }
                Inst.Volume = _Volume;
                Inst.Pan    = _Pan;
                Requests    = 2;
            }

            //SubmitBuffer(null, null);
            //SubmitBuffer(null, null);

            DecoderThread = new Thread(() =>
            {
                try
                {
                    while (Active && MainThread.IsAlive)
                    {
                        DecodeNext.WaitOne(128);
                        bool go;
                        lock (this) go = Requests > 0;
                        while (go)
                        {
                            var buf  = new byte[262144];// 524288];
                            var read = Stream.Read(buf, 0, buf.Length);
                            lock (this)
                            {
                                Requests--;
                                NextBuffers.Add(buf);
                                NextSizes.Add(read);
                                if (read == 0)
                                {
                                    EndOfStream = true;
                                    BufferDone.Set();
                                    return;
                                }
                                BufferDone.Set();
                            }
                            lock (this) go = Requests > 0;
                        }
                    }
                }
                catch (Exception e) { }
            });
            DecoderThread.Start();
            DecodeNext.Set();
        }
Exemple #13
0
 public override void Pause() => instance.Pause();
Exemple #14
0
 public override void Pause()
 {
     m_SoundInstance.Pause();
 }
Exemple #15
0
 /// <summary>
 /// Pauses playback.
 /// </summary>
 public void Pause()
 {
     sfx.Pause();
 }
Exemple #16
0
 public void Pause()
 {
     instance.Pause();
 }
Exemple #17
0
 public void Pause()
 {
     _dsei.Pause();
 }
Exemple #18
0
 internal void Pause()
 {
     soundStream.Pause();
 }
Exemple #19
0
 public void Pause()
 {
     mSoundEffectInstance.Pause();
 }
Exemple #20
0
 internal void Pause()
 {
     soundStream.Pause();
     timer.Stop();
 }
Exemple #21
0
 public void Pause()
 {
     chipSound.Pause();
 }