Merge pull request #5101 from zhongerxll/fix-media-control

Add timer button to system media controls for samsung
This commit is contained in:
zhongerxll
2025-05-29 06:33:18 -05:00
committed by GitHub
parent 179cc45e80
commit bce208c9df

View File

@@ -444,6 +444,14 @@ abstract class BaseReadAloudService : BaseService(),
PlaybackStateCompat.Builder()
.setActions(MediaHelp.MEDIA_SESSION_ACTIONS)
.setState(state, nowSpeak.toLong(), 1f)
// 为系统媒体控件添加定时按钮
.addCustomAction(
PlaybackStateCompat.CustomAction.Builder(
"ACTION_ADD_TIMER",
getString(R.string.set_timer),
R.drawable.ic_time_add_24dp
).build()
)
.build()
)
}
@@ -478,6 +486,9 @@ abstract class BaseReadAloudService : BaseService(),
override fun onStop() {
stopSelf()
}
override fun onCustomAction(action: String, extras: Bundle?) {
if (action == "ACTION_ADD_TIMER") addTimer()
}
override fun onMediaButtonEvent(mediaButtonEvent: Intent): Boolean {
return MediaButtonReceiver.handleIntent(this@BaseReadAloudService, mediaButtonEvent)
}