public override void OnReceive(Context context, Intent intent)
        {
            var action = intent.Action;

            LogHelper.Debug(Tag, "Received intent with action " + action);
            switch (action)
            {
            case ActionPause:
                transportControls.Pause();
                break;

            case ActionPlay:
                transportControls.Play();
                break;

            case ActionNext:
                transportControls.SkipToNext();
                break;

            case ActionPrev:
                transportControls.SkipToPrevious();
                break;

            default:
                LogHelper.Warn(Tag, "Unknown intent ignored. Action=", action);
                break;
            }
        }
Exemplo n.º 2
0
        private void Jukebox_MediaEvent(object sender, MediaActionEventArgs e)
        {
            switch (e.MediaActionFlags)
            {
            case MediaActionFlags.Play:
                _transportControls?.Play();
                break;

            case MediaActionFlags.Pause:
                _transportControls?.Pause();
                break;

            case MediaActionFlags.SkipToNext:
                _transportControls?.SkipToNext();
                break;

            case MediaActionFlags.SkipToPrevious:
                _transportControls?.SkipToPrevious();
                break;

            case MediaActionFlags.SeekTo:
                _transportControls?.SeekTo(e.Time);
                break;

            case MediaActionFlags.FastFoward:
                _transportControls?.FastForward();
                break;

            case MediaActionFlags.Rewind:
                _transportControls?.Rewind();
                break;

            case MediaActionFlags.Stop:
                _transportControls?.Stop();
                break;

            case MediaActionFlags.Replay:
                _transportControls?.Stop();
                _transportControls?.Play();
                break;

            case MediaActionFlags.RetrieveMediaInformation:
                //Send media information.
                if (_mediaMetadata != null)
                {
                    OnMediaMetadataChanged(new MediaMetadataChangedEventArgs
                    {
                        MediaMetadata      = _mediaMetadata,
                        ActivityIntent     = _activityIntent,
                        AppName            = _appname,
                        OpenNotificationId = _openNotificationId
                    });
                }

                if (_playbackState != null)
                {
                    //Send Playbackstate of the media.
                    OnMediaPlaybackChanged(new MediaPlaybackStateChangedEventArgs
                    {
                        PlaybackState = _playbackState.State,
                        CurrentTime   = _playbackState.Position
                    });
                }

                break;

            default:
                break;
            }
        }