Skip to content

Commit

Permalink
Merge pull request #601 from DHD2280/beta
Browse files Browse the repository at this point in the history
OpQsHeader: misc improvements
  • Loading branch information
DHD2280 authored Sep 4, 2024
2 parents 353388e + ea4c0d1 commit 8c08138
Showing 1 changed file with 0 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1229,42 +1229,6 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
return false
}

private fun getActiveLocalMediaController(): MediaController? {
val mediaSessionManager = mContext.getSystemService(MediaSessionManager::class.java)
var localController: MediaController? = null
val remoteMediaSessionLists: MutableList<String> = ArrayList()

for (controller in mediaSessionManager.getActiveSessions(null)) {
val playbackInfo = controller.playbackInfo ?: continue
val playbackState = controller.playbackState ?: continue
if (playbackState.state != PlaybackState.STATE_PLAYING) continue

if (playbackInfo.playbackType == PlaybackInfo.PLAYBACK_TYPE_REMOTE) {
if (localController != null
&& localController.packageName == controller.packageName
) {
localController = null
}

if (!remoteMediaSessionLists.contains(controller.packageName)) {
remoteMediaSessionLists.add(controller.packageName)
}

continue
}

if (playbackInfo.playbackType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) {
if (localController == null
&& !remoteMediaSessionLists.contains(controller.packageName)
) {
localController = controller
}
}
}

return localController
}

private enum class MediaAction {
TOGGLE_PLAYBACK,
PLAY_PREVIOUS,
Expand Down

0 comments on commit 8c08138

Please sign in to comment.