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