gpt4 book ai didi

java - 如何使用 Android API 防止 YouTube 停止播放?

转载 作者:行者123 更新时间:2023-12-02 06:39:23 25 4
gpt4 key购买 nike

据我所知,使用适用于 Android 的 YouTube API,播放器在离开 View 时会自动停止。例如,当应用程序关闭或另一个 View 位于播放器顶部时。

但我见过这个应用程序:https://play.google.com/store/apps/details?id=com.mixerbox.mixerbox似乎已经找到了解决方法。在此应用程序中,当您关闭它时,视频不会停止并继续在后台播放。

有人知道如何实现这一点吗?

最佳答案

仅播放 YouTube 视频的音频违反了YouTube API Terms of Service :

Your API Client will not, and You will not encourage or create functionality for Your users or other third parties to:

9. promote separately the audio or video components of any YouTube audiovisual content made available through the YouTube API;


出于教育目的,请查看 Services开发者指南。

A Service is an application component that can perform long-running operations in the background and does not provide a user interface. Another application component can start a service and it will continue to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC). For example, a service might handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background

MixerBox您提到的应用程序很可能有一个Service,当系统执行其 Activity 的 onPause() 回调时,它将视频音频的播放委托(delegate)给该服务。这就是 MixerBox 允许您离开应用程序的方式,并且您仍然可以在此处播放视频中的音频。

关于java - 如何使用 Android API 防止 YouTube 停止播放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19294933/

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