媒体控件 #134

This commit is contained in:
HapeLee
2025-10-24 12:58:44 +08:00
parent 27a395e697
commit ecd112ed33
2 changed files with 14 additions and 14 deletions
@@ -443,11 +443,11 @@ class AudioPlayService : BaseService(),
* 更新媒体状态
*/
private fun upMediaSessionPlaybackState(state: Int) {
// mediaSessionCompat?.setPlaybackState(
// PlaybackStateCompat.Builder()
// .setActions(MEDIA_SESSION_ACTIONS)
// .setState(state, exoPlayer.currentPosition, 1f)
// .setBufferedPosition(exoPlayer.bufferedPosition)
mediaSessionCompat?.setPlaybackState(
PlaybackStateCompat.Builder()
.setActions(MEDIA_SESSION_ACTIONS)
.setState(state, exoPlayer.currentPosition, 1f)
.setBufferedPosition(exoPlayer.bufferedPosition)
// .addCustomAction(
// APP_ACTION_STOP,
// getString(R.string.stop),
@@ -458,8 +458,8 @@ class AudioPlayService : BaseService(),
// getString(R.string.set_timer),
// R.drawable.ic_time_add_24dp
// )
// .build()
// )
.build()
)
}
/**
@@ -442,11 +442,11 @@ abstract class BaseReadAloudService : BaseService(),
* 更新媒体状态
*/
private fun upMediaSessionPlaybackState(state: Int) {
// mediaSessionCompat.setPlaybackState(
// PlaybackStateCompat.Builder()
// .setActions(MediaHelp.MEDIA_SESSION_ACTIONS)
// .setState(state, nowSpeak.toLong(), 1f)
// // 为系统媒体控件添加定时按钮
mediaSessionCompat.setPlaybackState(
PlaybackStateCompat.Builder()
.setActions(MediaHelp.MEDIA_SESSION_ACTIONS)
.setState(state, nowSpeak.toLong(), 1f)
// 为系统媒体控件添加定时按钮
// .addCustomAction(
// PlaybackStateCompat.CustomAction.Builder(
// "ACTION_ADD_TIMER",
@@ -454,8 +454,8 @@ abstract class BaseReadAloudService : BaseService(),
// R.drawable.ic_time_add_24dp
// ).build()
// )
// .build()
// )
.build()
)
}
/**