Example #1
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));
        }
Example #2
0
 public SoundPlaybackEventArgs(SoundPlayback soundPlayback) : base(soundPlayback.Sound)
 {
     SoundPlayback = soundPlayback;
 }
Example #3
0
 public PlaybackEventArgs(SoundPlayback sound, bool fromStop) : base(sound)
 {
     this.FromStop = fromStop;
 }