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.RetrieveMediaInformation: //Send media information. OnMediaMetadataChanged(new MediaMetadataChangedEventArgs { MediaMetadata = MediaMetadata, ActivityIntent = ActivityIntent }); //Send Playbackstate of the media. OnMediaPlaybackChanged(new MediaPlaybackStateChangedEventArgs { PlaybackState = PlaybackState.State, CurrentTime = PlaybackState.Position }); break; default: break; } }
private void Jukebox_MediaEvent(object sender, MediaActionEventArgs e) { switch (e.MediaActionFlags) { //case MediaActionFlags.Play: // 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 Misc.MediaActionFlags.Stop: // TransportControls.Stop(); // break; //case Misc.MediaActionFlags.RetrieveMediaInformation: // //Send media information. // OnMediaMetadataChanged(new MediaMetadataChangedEventArgs // { // MediaMetadata = MediaMetadata // }); // //Send Playbackstate of the media. // OnMediaPlaybackChanged(new MediaPlaybackStateChangedEventArgs // { // PlaybackState = PlaybackState.State, // CurrentTime = PlaybackState.Position // }); // break; //default: // break; } }
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; } }
private void Jukebox_MediaEvent(object sender, MediaActionEventArgs e) { switch (e.MediaActionFlags) { case MediaActionFlags.Play: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaPlay)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaPlay)); break; case MediaActionFlags.Pause: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaPause)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaPause)); OnPlaybackStateChanged(RemoteControlPlayState.Paused); //Workaround: Manually Notifying that the media has been paused. //because Android is mediocre and won't do this, so my app won't know if the media was paused. //This could lead to some fun bugs, but //It's the best approach I have found. break; case MediaActionFlags.SkipToNext: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaNext)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaNext)); break; case MediaActionFlags.SkipToPrevious: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaPrevious)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaPrevious)); break; case MediaActionFlags.SeekTo: TransportControls.SeekTo(e.Time); break; case MediaActionFlags.FastFoward: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaFastForward)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaFastForward)); break; case MediaActionFlags.Rewind: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaRewind)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaRewind)); break; case MediaActionFlags.Stop: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaStop)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaStop)); break; case MediaActionFlags.Replay: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaStop)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaStop)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaPlay)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaPlay)); break; case MediaActionFlags.RetrieveMediaInformation: //Send media information. OnMediaMetadataChanged(new MediaMetadataChangedKitkatEventArgs { Title = MediaMetadata.GetString((MediaMetadataEditKey)MetadataKey.Title, ""), Artist = MediaMetadata.GetString((MediaMetadataEditKey)MetadataKey.Artist, ""), Album = MediaMetadata.GetString((MediaMetadataEditKey)MetadataKey.Album, ""), AlbumArt = MediaMetadata.GetBitmap(MediaMetadataEditKey.BitmapKeyArtwork, null), Duration = MediaMetadata.GetLong((MediaMetadataEditKey)MetadataKey.Duration, 0) }); //Send Playbackstate of the media. OnMediaPlaybackChanged(new MediaPlaybackStateChangedKitkatEventArgs { PlaybackState = PlaybackState, CurrentTime = CurrentMediaPosition, }); break; default: break; } }
private static void OnMediaEvent(MediaActionEventArgs e) { MediaEvent?.Invoke(null, e); }
private void Jukebox_MediaEvent(object sender, MediaActionEventArgs e) { switch (e.MediaActionFlags) { case MediaActionFlags.Play: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaPlay)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaPlay)); break; case MediaActionFlags.Pause: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaPause)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaPause)); break; case MediaActionFlags.SkipToNext: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaNext)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaNext)); break; case MediaActionFlags.SkipToPrevious: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaPrevious)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaPrevious)); break; case MediaActionFlags.SeekTo: TransportControls.SeekTo(e.Time); break; case MediaActionFlags.FastFoward: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaFastForward)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaFastForward)); break; case MediaActionFlags.Rewind: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaRewind)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaRewind)); break; case MediaActionFlags.Stop: TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.MediaStop)); TransportControls.SendMediaKeyEvent(new KeyEvent(KeyEventActions.Up, Keycode.MediaStop)); break; case MediaActionFlags.RetrieveMediaInformation: //Send media information. OnMediaMetadataChanged(new MediaMetadataChangedKitkatEventArgs { Title = MediaMetadata.GetString((MediaMetadataEditKey)MetadataKey.Title, ""), Artist = MediaMetadata.GetString((MediaMetadataEditKey)MetadataKey.Artist, ""), Album = MediaMetadata.GetString((MediaMetadataEditKey)MetadataKey.Album, ""), AlbumArt = MediaMetadata.GetBitmap(MediaMetadataEditKey.BitmapKeyArtwork, null), Duration = MediaMetadata.GetLong((MediaMetadataEditKey)MetadataKey.Duration, 0) }); //Send Playbackstate of the media. OnMediaPlaybackChanged(new MediaPlaybackStateChangedKitkatEventArgs { PlaybackState = PlaybackState, CurrentTime = CurrentMediaPosition, }); break; default: break; } }