Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play YouTube videos in background in android?

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.

like image 922
Amit Avatar asked Feb 10 '17 13:02

Amit


People also ask

How do I get YouTube to play in the background on my phone?

Pull down the notification shade, and you will see the media controls of the video that you just played. Now simply tap play and your video will start playing in the background.

Why can't YouTube play in the background Android?

If you've blocked notifications, the YouTube app might not be able to run smoothly and/or access the internet in the background. If this happens, you'll need to re-enable YouTube notifications at the OS level and, if you still don't want to receive notifications, you can disable them from the YouTube app settings.


3 Answers

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;"

like image 77
Stefan Avatar answered Nov 10 '22 15:11

Stefan


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

like image 38
swap Avatar answered Nov 10 '22 14:11

swap


Yes its possible and its easy. No installation, no root, no violations. Let me explain it.

Andriod 9 --> Settings --> Search Picture in Picture --> select YouTube --> Allow

Once Allow picture-in-picture is enabled. You can run YouTube in Background.

enter image description here enter image description here

like image 26
Surya R Praveen Avatar answered Nov 10 '22 15:11

Surya R Praveen