mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-09-06 04:47:55 +00:00
Fix hiding player controls when playing from media button
DefaultControlDispatcher was removed in ExoPlayer 2.16.0, so the class extending it that handled play/pause was removed in #8020. The new solution is to use an instance of ForwardingPlayer. Call sessionConnector.setPlayer with an instance of ForwardingPlayer that overrides play() and pause() and calls the callback methods.
This commit is contained in:
@@ -13,6 +13,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media.session.MediaButtonReceiver;
|
||||
|
||||
import com.google.android.exoplayer2.ForwardingPlayer;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector;
|
||||
|
||||
@@ -55,7 +56,17 @@ public class MediaSessionManager {
|
||||
|
||||
sessionConnector = new MediaSessionConnector(mediaSession);
|
||||
sessionConnector.setQueueNavigator(new PlayQueueNavigator(mediaSession, callback));
|
||||
sessionConnector.setPlayer(player);
|
||||
sessionConnector.setPlayer(new ForwardingPlayer(player) {
|
||||
@Override
|
||||
public void play() {
|
||||
callback.play();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
callback.pause();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
Reference in New Issue
Block a user