Skip to content

Commit

Permalink
Fix media session
Browse files Browse the repository at this point in the history
  • Loading branch information
samfundev committed Apr 30, 2023
1 parent 1030fb8 commit 588b5ef
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/src/main/java/com/perflyst/twire/fragments/StreamFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.media.MediaDescriptionCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
Expand Down Expand Up @@ -86,6 +87,7 @@
import com.google.android.exoplayer2.SeekParameters;
import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector;
import com.google.android.exoplayer2.ext.mediasession.TimelineQueueNavigator;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
Expand Down Expand Up @@ -513,6 +515,16 @@ private void initializePlayer() {
pendingIntent);
MediaSessionConnector mediaSessionConnector = new MediaSessionConnector(mediaSession);
mediaSessionConnector.setPlayer(player);
mediaSessionConnector.setQueueNavigator(new TimelineQueueNavigator(mediaSession) {
@NonNull
@Override
public MediaDescriptionCompat getMediaDescription(Player player, int windowIndex) {
return new MediaDescriptionCompat.Builder()
.setTitle(title)
.setSubtitle(mUserInfo.getDisplayName())
.build();
}
});
mediaSession.setActive(true);

playerNotificationManager = new PlayerNotificationManager.Builder(getContext(), PLAYER_NOTIFICATION_ID, PLAYER_NOTIFICATION_CHANNEL)
Expand All @@ -532,7 +544,7 @@ class MediaAdapter implements PlayerNotificationManager.MediaDescriptionAdapter

@Override
public CharSequence getCurrentContentTitle(Player player) {
return title;
return null;
}

@Nullable
Expand All @@ -544,7 +556,7 @@ public PendingIntent createCurrentContentIntent(Player player) {
@Nullable
@Override
public CharSequence getCurrentContentText(Player player) {
return mUserInfo.getDisplayName();
return null;
}

@Nullable
Expand Down

0 comments on commit 588b5ef

Please sign in to comment.