forked from TeamNewPipe/NewPipe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep MediaSessionCompat and MediaSessionConnector in a separate class
These objects need to live beyond the player for supporting MediaBrowserServiceCompat and Android Auto, so they need to move outside of the MediaSessionPlayerUi class.
- Loading branch information
Showing
4 changed files
with
70 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/src/main/java/org/schabi/newpipe/player/mediabrowser/MediaBrowserConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.schabi.newpipe.player.mediabrowser; | ||
|
||
import android.support.v4.media.session.MediaSessionCompat; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector; | ||
|
||
import org.schabi.newpipe.player.PlayerService; | ||
|
||
public class MediaBrowserConnector { | ||
private static final String TAG = MediaBrowserConnector.class.getSimpleName(); | ||
|
||
private final PlayerService playerService; | ||
private final @NonNull MediaSessionConnector sessionConnector; | ||
private final @NonNull MediaSessionCompat mediaSession; | ||
|
||
public MediaBrowserConnector(@NonNull final PlayerService playerService) { | ||
this.playerService = playerService; | ||
mediaSession = new MediaSessionCompat(playerService, TAG); | ||
sessionConnector = new MediaSessionConnector(mediaSession); | ||
sessionConnector.setMetadataDeduplicationEnabled(true); | ||
} | ||
|
||
public @NonNull MediaSessionConnector getSessionConnector() { | ||
return sessionConnector; | ||
} | ||
|
||
public void release() { | ||
mediaSession.release(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters