问题
I'm a beginner and I’m working on an android project in which I play youtube videos using Google YouTube data API. Is it possible to play the video in the background even after the user has switched to another app or pressed the home button? Is it possible to separate the audio from the video and stream that in the background? I don't want to use web view.
回答1:
It is possible to play the audio in the background. However , you are not allowed to do so.
This violation of the Youtube API is cause for immidiate removal from the play store.
Official answer:
During review, we found that your app violates the Prohibited Actions provision of the Content Policy.
We have determined that your app enables background playing of YouTube videos, which is a violation of the 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: (8) separate, isolate, or modify the audio or video components of any YouTube audiovisual content made available through the YouTube API;"
回答2:
youtube red users only they possible to play youtube videos in background (https://support.google.com/youtube/answer/6308116?hl=en). You can check if they have this in the api,
its possible to play youtube videos in background if you open the desktop version of youtube in a browser. Maybe you can make use of this by opening the correct link in a webview in background
来源:https://stackoverflow.com/questions/42160968/how-to-play-youtube-videos-in-background-in-android