Merge pull request #5101 from zhongerxll/fix-media-control
Add timer button to system media controls for samsung
This commit is contained in:
@@ -444,6 +444,14 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
PlaybackStateCompat.Builder()
|
PlaybackStateCompat.Builder()
|
||||||
.setActions(MediaHelp.MEDIA_SESSION_ACTIONS)
|
.setActions(MediaHelp.MEDIA_SESSION_ACTIONS)
|
||||||
.setState(state, nowSpeak.toLong(), 1f)
|
.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()
|
.build()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -478,6 +486,9 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
stopSelf()
|
stopSelf()
|
||||||
}
|
}
|
||||||
|
override fun onCustomAction(action: String, extras: Bundle?) {
|
||||||
|
if (action == "ACTION_ADD_TIMER") addTimer()
|
||||||
|
}
|
||||||
override fun onMediaButtonEvent(mediaButtonEvent: Intent): Boolean {
|
override fun onMediaButtonEvent(mediaButtonEvent: Intent): Boolean {
|
||||||
return MediaButtonReceiver.handleIntent(this@BaseReadAloudService, mediaButtonEvent)
|
return MediaButtonReceiver.handleIntent(this@BaseReadAloudService, mediaButtonEvent)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user