【问题标题】:ADB shell command to set media playback position in YouTube app on Android TVADB shell 命令在 Android TV 上的 YouTube 应用中设置媒体播放位置
【发布时间】:2021-09-06 18:15:40
【问题描述】:

概要

在我的 Android TV 上,我正在播放 YouTube 视频。有时我喜欢“倒带”到视频时间轴中的特定音乐曲目。我想用adb 自动化这个。

我想使用adb shell 命令向我的Android TV 发送指令,指示媒体播放位置应设置为特定值(以毫秒为单位)。使用adb logcat 命令,我发现正在发出以下日志条目。

问题:如何使用adb shell 跳转到 YouTube 视频时间轴中的特定拍号?

ADB Logcat 输出

09-06 10:45:39.807 28895 28895 I starboard_media: MediaSession state: PLAYING, position: 2393000 ms, speed: 1.000000 x, duration: 4216780 ms
09-06 10:45:39.809  2939  6629 D MediaSessionService: Media button session is changed to com.google.android.youtube.tv/starboard_media (userId=0)
09-06 10:45:39.812  3296  3296 I NewAvrcpMediaPlayerList: onAddressedPlayerChanged: token=com.google.android.youtube.tv
09-06 10:45:39.812  3296  3296 W NewAvrcpMediaPlayerList: com.google.android.youtube.tv is already the active player
09-06 10:45:39.814  4557  4557 D NowPlayingListener: updateNowPlayingNotification with controller: NowPlayingMediaController {packageName = com.google.android.youtube.tv, state = 3, metadata = Music For Efficient Work — Future Garage Playlist, Music Lab, null}
09-06 10:45:39.814  4557  4557 D NowPlayingManager: onClientChanged() called with: clearing = [false]
09-06 10:45:39.814  4557  4557 D NowPlayingListener: updateMetadata() called with: metadata description = [Music For Efficient Work — Future Garage Playlist, Music Lab, null] and now playing listener: dge@441b9b5
09-06 10:45:39.815  4334  4334 D AirPlayService: onActiveSessionsChanged: controller = com.google.android.youtube.tv
09-06 10:45:39.822  3296  3296 V NewAvrcpMediaPlayerWrapper: onPlaybackStateChanged(): com.google.android.youtube.tv : PlaybackState {state=3, position=2393000, buffered position=0, speed=1.0, updated=313779254, actions=379, custom actions=[], active item id=-1, error=null}
09-06 10:45:39.824  4334  4334 D AirPlayService: onActiveSessionsChanged : Playback state = 3
09-06 10:45:39.826  3296  3296 W NewAvrcpMediaPlayerWrapper: onPlaybackStateChanged(): com.google.android.youtube.tv tried to update with no new data
09-06 10:45:39.826  5384  5384 D BasicMediaStatusFactory: Supported media session actions: 379
09-06 10:45:39.829  3296  3296 V NewAvrcpMediaPlayerWrapper: onMetadataChanged(): com.google.android.youtube.tv : { mediaId="currsong" title="Music For Efficient Work — Future Garage Playlist" artist="Music Lab" album="" duration=4216780 trackPosition=1/1 }
09-06 10:45:39.829  5384  5384 D WargMsAppMgr: A new media session detected: com.google.android.youtube.tv
09-06 10:45:39.829  5384  5384 D WargMsAppMgr: Active app is the same session. Ignore.
09-06 10:45:39.830  3370  3425 W SSServ_MediaSessionHelper: Playback state is PlaybackState {state=3, position=2393021, buffered position=0, speed=1.0, updated=313779275, actions=379, custom actions=[], active item id=-1, error=null}.
09-06 10:45:39.834  2591  3209 D SurfaceFlinger: getDisplayConfigs hwc config w:1920 h:1080
09-06 10:45:39.835  5384  5384 D BasicMediaStatusFactory: Supported media session actions: 379
09-06 10:45:39.837  2067  2642 I hwcomposer: same layer type is change to 3 from 3 for the same layer id
09-06 10:45:39.839  3296  3296 V NewAvrcpMediaPlayerWrapper: trySendMediaUpdate(): Metadata has been updated for com.google.android.youtube.tv
09-06 10:45:39.839  3296  3296 D NewAvrcpMediaPlayerList: sendMediaUpdate
09-06 10:45:39.839  3296  3296 I NewAvrcpMediaPlayerList: sendMediaUpdate: Creating a one item queue for a player with no queue
09-06 10:45:39.839  3296  3296 D NewAvrcpTargetService: onMediaUpdated: track_changed=false state=false queue=false
09-06 10:45:39.839  3296  3296 D NewAvrcpNativeInterface: sendMediaUpdate: metadata=false playStatus=false queue=false
09-06 10:45:39.839  3296  3296 D NewAvrcpTargetJni: sendMediaUpdateNative
09-06 10:45:39.839  3296  3296 I bt_stack: [INFO:avrcp_service.cc(342)] virtual void bluetooth::avrcp::AvrcpService::SendMediaUpdate(bool, bool, bool) track_changed=0 :  play_state=0 :  queue=0
09-06 10:45:39.840  2591  2620 D SurfaceFlinger: getDisplayConfigs hwc config w:1920 h:1080
09-06 10:45:39.840  3296  3296 V NewAvrcpMediaPlayerList: onActiveSessionsChanged: number of controllers: 1
09-06 10:45:39.841  3296  3296 D NewAvrcpMediaPlayerList: onActiveSessionsChanged: controller: com.google.android.youtube.tv
09-06 10:45:39.841  3296  3296 D NewAvrcpMediaPlayerList: Already have a controller for the player: com.google.android.youtube.tv, updating instead
09-06 10:45:39.845  3296  3296 D NewAvrcpMediaPlayerWrapper: com.google.android.youtube.tv: Controller for com.google.android.youtube.tv was updated.
09-06 10:45:39.847  3296  3296 D NewAvrcpMediaPlayerList: sendMediaUpdate
09-06 10:45:39.847  3296  3296 I NewAvrcpMediaPlayerList: sendMediaUpdate: Creating a one item queue for a player with no queue
09-06 10:45:39.847  3296  3296 D NewAvrcpTargetService: onMediaUpdated: track_changed=false state=false queue=false
09-06 10:45:39.847  3296  3296 D NewAvrcpNativeInterface: sendMediaUpdate: metadata=false playStatus=false queue=false
09-06 10:45:39.847  3296  3296 D NewAvrcpTargetJni: sendMediaUpdateNative
09-06 10:45:39.847  3296  3296 I bt_stack: [INFO:avrcp_service.cc(342)] virtual void bluetooth::avrcp::AvrcpService::SendMediaUpdate(bool, bool, bool) track_changed=0 :  play_state=0 :  queue=0
09-06 10:45:39.851  4557  4557 D NowPlayingManager: onMediaDataUpdated() called with: NowPlayingData [dfz@e669f31, title=Music For Efficient Work — Future Garage Playlist, artist=Music Lab]
09-06 10:45:39.857  4557  4557 D NowPlayingManager: onMediaDataUpdated: A notification for Now Playing Card has been posted with NowPlayingData [title=Music For Efficient Work — Future Garage Playlist, artist=Music Lab]
09-06 10:45:39.858  4557  4557 D NowPlayingListener: updatePlayback() called with: state = [PlaybackState {state=3, position=2393000, buffered position=0, speed=1.0, updated=313779254, actions=379, custom actions=[], active item id=-1, error=null}] and now playing listener: dge@441b9b5

【问题讨论】:

    标签: android adb


    【解决方案1】:

    您不能使用adb 命令强制应用跳转到特定时间,但您应该能够模拟媒体按钮单击以向前或向后跳过预设的秒数。

    查看此答案了解详情:https://stackoverflow.com/a/8483797/10302746

    你可能想要这样的东西:

    adb shell input keyevent 21
    

    模拟左键,应该快退 5 到 10 秒。

    【讨论】:

    • 谢谢,我知道如何做一些简单的事情,比如播放/暂停。我希望根据应用程序日志,我可以向 YouTube 应用程序发送一个意图,表明我希望它跳转到哪个位置。例如,从日志中查看此文本:{state=3, position=2393021, buffered position=0, speed=1.0, updated=313779275, actions=379, custom actions=[], active item id=-1, error=null}
    • 如果我能弄清楚如何构建一个意图,我想我可以使用adb shell am 将它发送到 YouTube 应用程序。但是,我想我还需要知道我想发送意图的活动的名称,根据这个答案:stackoverflow.com/questions/22634446/…
    • @TrevorSullivan 该日志未表明已收到意图。只是触发了应用程序内的回调。据我所知,youtube 应用程序不是为接收您想要发送的意图而构建的。但我可能是错的。您可以尝试使用 apktool 之类的东西反编译 APK 并查看清单。它会告诉你它可以接收什么样的意图以及接收它们的活动。
    猜你喜欢
    • 2014-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-20
    相关资源
    最近更新 更多