Exemplo n.º 1
0
        public async Task PlayNext()
        {
            await RaiseMediaFileFailedEventOnException(async() =>
            {
                if (MediaQueue.HasNext())
                {
                    MediaQueue.SetNextAsCurrent();

                    await PlayCurrent();
                }
                else
                {
                    MediaQueue.SetIndexAsCurrent(0);

                    await PrepareCurrentAndThen(async() =>
                    {
                        await CurrentPlaybackManager.Play();
                        await CurrentPlaybackManager.Pause();
                        await Seek(TimeSpan.Zero);
                    });

                    OnMediaFileChanged(this, new MediaFileChangedEventArgs(CurrentMediaFile));
                }
            });
        }
        public async Task PlayNext()
        {
            try
            {
                if (MediaQueue.HasNext())
                {
                    //await CurrentPlaybackManager.Pause();
                    MediaQueue.SetNextAsCurrent();
                    var beforePlayTask = _onBeforePlay?.Invoke(_currentMediaFile);
                    if (beforePlayTask != null)
                    {
                        await beforePlayTask;
                    }
                    await Task.WhenAll(
                        CurrentPlaybackManager.Play(_currentMediaFile),
                        GetMediaInformation(new[] { _currentMediaFile }));
                }
                else
                {
                    await CurrentPlaybackManager.Pause();

                    MediaQueue.SetIndexAsCurrent(0);
                    OnMediaFileChanged(this, new MediaFileChangedEventArgs(MediaQueue.Current));
                }
            }
            catch (Exception ex)
            {
                OnMediaFileFailed(CurrentPlaybackManager, new MediaFileFailedEventArgs(ex, _currentMediaFile));
                throw;
            }
        }
        public async Task PlayPause()
        {
            switch (Status)
            {
            case MediaPlayerStatus.Paused:
                await CurrentPlaybackManager.Play(_currentMediaFile);

                break;

            case MediaPlayerStatus.Stopped:
                await Play(_currentMediaFile);

                break;

            default:
                await CurrentPlaybackManager.Pause();

                break;
            }
        }
 public async Task Pause()
 {
     await CurrentPlaybackManager.Pause();
 }