Example #1
0
 async void AudioPlayer_MediaEnded(MediaPlayer sender, object args)
 {
     await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         FinishedPlaying?.Invoke(this, EventArgs.Empty);
     });
 }
Example #2
0
 public void PlayAsync(string code)
 {
     Task.Run(() =>
     {
         PlaySequence(code);
         FinishedPlaying?.Invoke(this, EventArgs.Empty);
     });
 }
Example #3
0
        private Task OnSpeakingUpdated(ulong userId, bool isPlaying)
        {
            _isPlaying = isPlaying;

            if (!isPlaying)
            {
                FinishedPlaying.Invoke(this, new FinishedPlayingEventArgs());
            }

            return(Task.CompletedTask);
        }
Example #4
0
        public async Task StopAsync()
        {
            _isPlaying = false;

            if (_client != null)
            {
                await _client.StopAsync();

                FinishedPlaying.Invoke(this, new FinishedPlayingEventArgs(true));
            }
        }
Example #5
0
    private void CommandsFinished()
    {
        switch (state)
        {
        case State.MOVING:
            state = State.ACTIVATING;
            if (AddActivations())
            {
                ExecuteCommands();
            }
            else
            {
                CommandsFinished();
            }
            break;

        case State.ACTIVATING:
            state = State.FILLING;
            if (AddObjectivesToFill())
            {
                ExecuteCommands();
            }
            else
            {
                CommandsFinished();
            }
            break;

        case State.FILLING:
            state = State.PLAYED;
            FinishedPlaying.Invoke();
            break;

        case State.UNFILLING:
            state = State.UNACTIVATING;
            UnActivateEffects();
            break;

        case State.UNACTIVATING:
            state = State.UNMOVING;
            UnMoveBricks();
            break;

        case State.UNMOVING:
            state = State.FINISHED;
            FinishedPlaying.Invoke();
            break;

        default:
            throw new Exception("State :" + state + " - Can't finish commands if no turn was playing");
        }
    }
        /// <summary>
        /// Handler for if playback of a file stopped.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">StoppedEventArgs.</param>
        /// <returns>Task instance.</returns>
        private async void OnPlaybackStoppedAsync(object sender, StoppedEventArgs e)
        {
            await Task.Run(() =>
            {
                bool stoppedExplicitly;

                lock (this)
                {
                    // Dispose timer so we stop reporting the position
                    if (_positionReportTimer != null)
                    {
                        _positionReportTimer.Dispose();
                        _positionReportTimer = null;
                        // Also indicate we don't want to report because the event may have already been fired
                        _doNotReportPosition = true;
                    }

                    // Dispose the wavestream
                    _waveStream.Dispose();

                    // Set resuming to false so we know we're not resuming the next time we start
                    _paused = false;

                    stoppedExplicitly = _stoppedExplicitly;

                    // Signal reset event
                    _resetEvent.Set();
                }

                // If playback wasn't stopped explicitly that meanse the track finished on it's own
                if (stoppedExplicitly)
                {
                    StoppedPlaying?.Invoke(this, new FinishedStoppedPlayingEventArgs(_trackId));
                }
                else
                {
                    FinishedPlaying?.Invoke(this, new FinishedStoppedPlayingEventArgs(_trackId));
                }
            });
        }
Example #7
0
        void Player_FinishedPlaying(object sender, AVStatusEventArgs e)
        {
            if (currentAVAudioSessionCategory != null)
            {
                var audioSession = AVAudioSession.SharedInstance();

                if (audioSession.SetCategory(currentAVAudioSessionCategory, out NSError err))
                {
                    currentAVAudioSessionCategory = null;                     //reset this if success, otherwise hang onto it to possibly try again
                }
                else
                {
                    // we won't error out here as this likely won't prevent us from stopping properly... but we will log an issue
                    Debug.WriteLine($"Error attempting to set the AVAudioSession category back to {currentAVAudioSessionCategory} :: {err}");
                }

                // allow for additional audio session reset/config
                OnResetAudioSession?.Invoke(audioSession);
            }

            FinishedPlaying?.Invoke(this, EventArgs.Empty);
        }
Example #8
0
 void Finish()
 {
     IsPlaying = false;
     FinishedPlaying?.Invoke();
 }
 private void MediaPlayer_Completion(object sender, EventArgs e)
 {
     FinishedPlaying?.Invoke(this, EventArgs.Empty);
 }
Example #10
0
 private void Player_FinishedPlaying(object sender, AVStatusEventArgs e)
 {
     FinishedPlaying?.Invoke(this, EventArgs.Empty);
 }
Example #11
0
 private void OnFinishedPlaying(object obj)
 {
     FinishedPlaying?.Invoke(this, EventArgs.Empty);
 }