Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1501fe6f authored by Ted Wang's avatar Ted Wang Committed by Cheney Ni
Browse files

Set active player to MediaKeyEventSession when init

Active player of MediaPlayerList should be set to player get from
MediaSessionManager instead of pending callback from Media framework
when init MediaPlayerList.

Bug: 209731732
Test: Manual

Change-Id: I4269f7b0bbde97358c80697f8bbe9e515a6f0148
parent cfc4b2f5
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -196,7 +196,16 @@ public class MediaPlayerList {

                // If there were any active players and we don't already have one due to the Media
                // Framework Callbacks then set the highest priority one to active
                if (mActivePlayerId == 0 && mMediaPlayers.size() > 0) setActivePlayer(1);
                if (mActivePlayerId == 0 && mMediaPlayers.size() > 0) {
                    String packageName = mMediaSessionManager.getMediaKeyEventSessionPackageName();
                    if (!TextUtils.isEmpty(packageName) && haveMediaPlayer(packageName)) {
                        Log.i(TAG, "Set active player to MediaKeyEvent session = " + packageName);
                        setActivePlayer(mMediaPlayerIds.get(packageName));
                    } else {
                        Log.i(TAG, "Set active player to first default");
                        setActivePlayer(1);
                    }
                }
            });
    }