有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何使用Android API阻止youtube停止播放?

据我所知,通过Android的YouTube API,播放器在看不见的时候会自动停止。例如,当应用程序关闭或另一个视图位于播放器顶部时

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

有人知道如何做到这一点吗


共 (1) 个答案

  1. # 1 楼答案

    仅播放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()回调时,它会将视频音频的播放委托给该应用程序。这就是MixerBox允许您离开应用程序的方式,您仍然可以在这里播放视频中的音频