gpt4 book ai didi

安卓小工具 : skip_to_next and skip_to_previous buttons don't work

转载 作者:行者123 更新时间:2023-11-29 00:02:46 25 4
gpt4 key购买 nike

我目前正在尝试为音频应用程序开发一个小部件。该小部件包括一个跳到上一个、一个播放和一个跳到下一个按钮,如下图所示。

enter image description here

我关注了这个 recommended approach并且 play_pause 按钮​​工作正常,但目前仅在播放开始时有效。

To start the playback the user must 1) Open the app. 2) Choose a podcast. 3) Choose an episode to play. 4) Wait for the buffering to complete

只需为 play_pause 按钮​​设置正确的 PendingIntent 即可。因此,当单击此按钮时,将调用我的 MediaSession.Callback.onPlay() 方法。

不幸的是,skip_to_nextskip_to_previous 按钮不是这种情况。我希望在单击 skip_to_next 小部件按钮时调用 MediaSession.Callback.onSkipToNext()

这是我的 AppWidgetProvider类和 MediaBrowserService

最佳答案

我不确定这是否是完整的解决方案,但似乎没有注册上一个和下一个按钮?

我之前并没有真正使用过 MediaButtonReceiver 所以我猜,但是我在 PlayBackUtils 现在代码确实接收到上一个事件并且实际上也更改为上一个轨道。

case STARTED:
return stateBuilder
.setState(PlaybackStateCompat.STATE_PLAYING,
currentPosition, playbackSpeed)
.setActions(PlaybackStateCompat.ACTION_PAUSE |
PlaybackStateCompat.ACTION_PLAY_PAUSE |
PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
PlaybackStateCompat.ACTION_STOP |
PlaybackStateCompat.ACTION_SEEK_TO |
PlaybackStateCompat.ACTION_PLAY)
.build();

关于安卓小工具 : skip_to_next and skip_to_previous buttons don't work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51366976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com