Exemplo n.º 1
0
 /// <summary>
 /// Private callback for when the Source is finished playing and will be returned to the pool.
 /// </summary>
 /// <param name="source">The source that triggered the callback.</param>
 private void finished(IntPtr source)
 {
     if (PlaybackFinished != null)
     {
         PlaybackFinished.Invoke(this);
     }
 }
Exemplo n.º 2
0
 private void HandlePlaybackFinished(object sender, ElapsedEventArgs e)
 {
     Playing = false;
     PlaybackFinished?.Invoke(this, e);
     _playbackTimer.Dispose();
     _playbackTimer = null;
 }
Exemplo n.º 3
0
        public Task Play(SoundboxContext context, SoundPlayback sound)
        {
            if (Finished)
            {
                return(Task.FromResult(false));
            }

            this.Sound     = sound;
            this.WavPlayer = new System.Media.SoundPlayer(context.GetAbsoluteFileName(sound.Sound));

            new System.Threading.Thread(() =>
            {
                WavPlayer.PlaySync();
                lock (this)
                {
                    if (Finished)
                    {
                        return;
                    }
                    Finished = true;

                    PlaybackFinished?.Invoke(this, new ISoundPlaybackService.PlaybackEventArgs(
                                                 sound: sound,
                                                 fromStop: false
                                                 ));
                }
            }).Start();

            return(Task.FromResult(true));
        }
Exemplo n.º 4
0
 protected virtual void WaveOutDevice_PlaybackStopped(object sender, StoppedEventArgs e)
 {
     if (_playbackAborted)
     {
         return;
     }
     PlaybackFinished?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 5
0
 internal void HandlePlaybackFinished(object sender, EventArgs e)
 {
     if (Playing)
     {
         Playing = false;
         PlaybackFinished?.Invoke(this, e);
     }
 }
Exemplo n.º 6
0
 private void HandlePlaybackFinished(object sender, ElapsedEventArgs e)
 {
     Stop();
     ExecuteMsiCommand("Close All");
     Playing = false;
     PlaybackFinished?.Invoke(this, e);
     _playbackTimer.Dispose();
     _playbackTimer = null;
 }
Exemplo n.º 7
0
        private void Playback_Finished(object sender, EventArgs e)
        {
            // The finished event fires 5 seconds before the last note finished playing,
            // due to difference between display and audio, leaving one second of buffer.
            Task.Delay(6000).ContinueWith(t =>
            {
                this.startTimer?.Dispose();
                this.threadCancellationToken.Cancel();
                this.startThreadCancellationToken.Cancel();
                this.playback?.Dispose();
                this.outputDevice?.Dispose();

                PlaybackFinished?.Invoke(this, null);
            });
        }
Exemplo n.º 8
0
        public void OnSoundStopped(ISound sound, StopEventCause reason, object userData)
        {
            lock (this)
            {
                if (Finished)
                {
                    return;
                }
                Finished = true;
            }
            //this throws an error
            //TODO make sure the sound is disposed eventually
            //sound.Dispose();

            PlaybackFinished?.Invoke(this, new ISoundPlaybackService.PlaybackEventArgs(
                                         sound: this.Sound,
                                         fromStop: false
                                         ));
        }
Exemplo n.º 9
0
        public void Stop()
        {
            lock (this)
            {
                if (Finished)
                {
                    return;
                }
                Finished = true;
            }

            Playback?.Stop();
            Playback?.Dispose();

            //notify listeners
            PlaybackFinished?.Invoke(this, new ISoundPlaybackService.PlaybackEventArgs(
                                         sound: this.Sound,
                                         fromStop: true
                                         ));
        }
Exemplo n.º 10
0
        public void Stop()
        {
            lock (this)
            {
                if (Finished)
                {
                    return;
                }
                Finished = true;
            }

            if (WavPlayer != null)
            {
                WavPlayer.Stop();
            }

            PlaybackFinished?.Invoke(this, new ISoundPlaybackService.PlaybackEventArgs(
                                         sound: this.Sound,
                                         fromStop: true
                                         ));
        }
Exemplo n.º 11
0
 private void OnPlaybackFinished(object sender, EventArgs e)
 {
     PlaybackFinished?.Invoke(this, e);
 }
Exemplo n.º 12
0
 public AudioPlayer()
 {
     _impl                = CrossSimpleAudioPlayer.Current;
     _impl.Loop           = false;
     _impl.PlaybackEnded += (o, e) => PlaybackFinished?.Invoke();
 }
Exemplo n.º 13
0
 public void FirePlaybackFinished(object sender, EventArgs args)
 {
     PlaybackFinished?.Invoke(sender, args);
 }
Exemplo n.º 14
0
 protected virtual void OnPlaybackFinished(EventArgs e)
 {
     PlaybackFinished?.Invoke(this, e);
 }