Skip to content

Commit cc25535

Browse files
Fix crash in MediaSessionPlayerUi while destroying player
Author: Stypox
1 parent ea0b317 commit cc25535

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/src/main/java/org/schabi/newpipe/player/mediasession/MediaSessionPlayerUi.java

+7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ public class MediaSessionPlayerUi extends PlayerUi
3838
implements SharedPreferences.OnSharedPreferenceChangeListener {
3939
private static final String TAG = "MediaSessUi";
4040

41+
@Nullable
4142
private MediaSessionCompat mediaSession;
43+
@Nullable
4244
private MediaSessionConnector sessionConnector;
4345

4446
private final String ignoreHardwareMediaButtonsKey;
@@ -198,6 +200,11 @@ private void updateMediaSessionActions() {
198200
return;
199201
}
200202

203+
if (sessionConnector == null) {
204+
// sessionConnector will be null after destroyPlayer is called
205+
return;
206+
}
207+
201208
// only use the fourth and fifth actions (the settings page also shows only the last 2 on
202209
// Android 13+)
203210
final List<NotificationActionData> newNotificationActions = IntStream.of(3, 4)

0 commit comments

Comments
 (0)