예제 #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);
     }
 }
예제 #2
0
 private void HandlePlaybackFinished(object sender, ElapsedEventArgs e)
 {
     Playing = false;
     PlaybackFinished?.Invoke(this, e);
     _playbackTimer.Dispose();
     _playbackTimer = null;
 }
예제 #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));
        }
예제 #4
0
 protected virtual void WaveOutDevice_PlaybackStopped(object sender, StoppedEventArgs e)
 {
     if (_playbackAborted)
     {
         return;
     }
     PlaybackFinished?.Invoke(this, EventArgs.Empty);
 }
예제 #5
0
 internal void HandlePlaybackFinished(object sender, EventArgs e)
 {
     if (Playing)
     {
         Playing = false;
         PlaybackFinished?.Invoke(this, e);
     }
 }
예제 #6
0
 private void HandlePlaybackFinished(object sender, ElapsedEventArgs e)
 {
     Stop();
     ExecuteMsiCommand("Close All");
     Playing = false;
     PlaybackFinished?.Invoke(this, e);
     _playbackTimer.Dispose();
     _playbackTimer = null;
 }
예제 #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);
            });
        }
예제 #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
                                         ));
        }
예제 #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
                                         ));
        }
예제 #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
                                         ));
        }
예제 #11
0
 private void OnPlaybackFinished(object sender, EventArgs e)
 {
     PlaybackFinished?.Invoke(this, e);
 }
예제 #12
0
 public AudioPlayer()
 {
     _impl                = CrossSimpleAudioPlayer.Current;
     _impl.Loop           = false;
     _impl.PlaybackEnded += (o, e) => PlaybackFinished?.Invoke();
 }
예제 #13
0
 public void FirePlaybackFinished(object sender, EventArgs args)
 {
     PlaybackFinished?.Invoke(sender, args);
 }
예제 #14
0
 protected virtual void OnPlaybackFinished(EventArgs e)
 {
     PlaybackFinished?.Invoke(this, e);
 }