如何使用Android API阻止youtube停止播放? [英] How do I prevent youtube stop playback using Android API?

查看:335
本文介绍了如何使用Android API阻止youtube停止播放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,使用适用于Android的YouTube API,播放器会在视野开始时自动停止。例如,当应用关闭或其他视图位于播放器顶部时。

As far as I know, with the YouTube API for Android, the player automatically stops when it's out of view. For example, when the app is closed or when another view is positioned on top of the player.

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

But I've seen this application: https://play.google.com/store/apps/details?id=com.mixerbox.mixerbox that seems to have found a workaround for this. In this app, when you close it, the video doesn't stops and continues playing in the background.

任何人都知道如何实现这一目标?

Anyone know how this can be achieved?

推荐答案

仅播放YouTube视频的音频违反 YouTube API服务条款

To play only the audio of a YouTube video violates the YouTube API Terms of Service:


您的API客户端不会,并且您不会鼓励或创建您的用户或其他第三方的功能:


9.单独宣传通过YouTube API提供的任何YouTube视听内容的音频或视频组件;

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;



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


A Service是一个可以执行长时间运行的应用程序组件在后台的口粮并没有提供用户界面。另一个应用程序组件可以启动服务,即使用户切换到另一个应用程序,它也将继续在后台运行。此外,组件可以绑定到服务以与其交互,甚至可以执行进程间通信(IPC)。例如,服务可能处理网络事务,播放音乐,执行文件I / O或与内容提供商交互,所有这些都来自后台

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 应用最有可能一个服务它将视频音频的回放委托给它的'活动的 onPause()回调是由系统。这就是 MixerBox 允许你离开应用程序的方式,你仍然可以在这里播放视频中播放的音频。

The MixerBox app you mention most likely has a Service that it delegates the play back of the video's audio to when its' Activity's onPause() callback is executed by the system. That is how MixerBox allows you to navigate away from the application and you can still here the audio playing from the video.

这篇关于如何使用Android API阻止youtube停止播放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆