Pass keyevents from the session to MediaPlayerLifecycleSupport
This commit is contained in:
parent
88f6bdb3a9
commit
8bfc5d04ef
|
@ -183,7 +183,7 @@ public class MediaPlayerLifecycleSupport
|
||||||
context.registerReceiver(headsetEventReceiver, headsetIntentFilter);
|
context.registerReceiver(headsetEventReceiver, headsetIntentFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleKeyEvent(KeyEvent event)
|
public void handleKeyEvent(KeyEvent event)
|
||||||
{
|
{
|
||||||
if (event.getAction() != KeyEvent.ACTION_DOWN || event.getRepeatCount() > 0)
|
if (event.getAction() != KeyEvent.ACTION_DOWN || event.getRepeatCount() > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,6 +71,7 @@ public class MediaPlayerService extends Service
|
||||||
private final Lazy<Downloader> downloaderLazy = inject(Downloader.class);
|
private final Lazy<Downloader> downloaderLazy = inject(Downloader.class);
|
||||||
private final Lazy<LocalMediaPlayer> localMediaPlayerLazy = inject(LocalMediaPlayer.class);
|
private final Lazy<LocalMediaPlayer> localMediaPlayerLazy = inject(LocalMediaPlayer.class);
|
||||||
private final Lazy<NowPlayingEventDistributor> nowPlayingEventDistributor = inject(NowPlayingEventDistributor.class);
|
private final Lazy<NowPlayingEventDistributor> nowPlayingEventDistributor = inject(NowPlayingEventDistributor.class);
|
||||||
|
private final Lazy<MediaPlayerLifecycleSupport> mediaPlayerLifecycleSupport = inject(MediaPlayerLifecycleSupport.class);
|
||||||
|
|
||||||
private LocalMediaPlayer localMediaPlayer;
|
private LocalMediaPlayer localMediaPlayer;
|
||||||
private Downloader downloader;
|
private Downloader downloader;
|
||||||
|
@ -893,6 +894,17 @@ public class MediaPlayerService extends Service
|
||||||
super.onSeekTo(pos);
|
super.onSeekTo(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onMediaButtonEvent(Intent mediaButtonEvent) {
|
||||||
|
// This probably won't be necessary once we implement more
|
||||||
|
// of the modern media APIs, like the MediaController etc.
|
||||||
|
KeyEvent event = (KeyEvent) mediaButtonEvent.getExtras().get("android.intent.extra.KEY_EVENT");
|
||||||
|
MediaPlayerLifecycleSupport lifecycleSupport = mediaPlayerLifecycleSupport.getValue();
|
||||||
|
lifecycleSupport.handleKeyEvent(event);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue