0

How can I control the speed from an exo player via the UI to MediaBrowserServiceCompat?

Does Android provide a normal solution for it?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

1 Answers1

0

In the end, I did it like this.

In the activity I did this:

MediaControllerCompat.getMediaController(ChatActivity.this).sendCommand("speed",bundle,new ResultReceiver(new Handler(Looper.getMainLooper()))

And in the MediaBrowserServiceCompat I did it like this:

private MediaSessionConnector.QueueEditor getQueueEditor() {
    return new MediaSessionConnector.QueueEditor() {
        @Override
        public boolean onCommand(Player player, String command, @Nullable Bundle extras, @Nullable ResultReceiver cb) {
            float speed = extras.getFloat("SpeedProgress");
            PlaybackParameters param = new PlaybackParameters(speed);
            player.setPlaybackParameters(param);
            player.setPlaybackSpeed(speed);
            return false;
        }
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131