Reputation: 51
is it possible to play youtube videos in a service while the device screen is locked (display off)? The YouTube API provides several ways, how to play a video, however, when I lock the device the playback stops. Android MediaPlayer can be simply played from a service and screen lock doesn't affect it...
Anyone has some experiences in this?
Any advice is very appreciated!
Thanks!
Upvotes: 2
Views: 2861
Reputation: 12339
The YouTube SDK prevents videos from being played in the background, simply because any existing YouTubePlayer
instance is destroyed when the Activity/Fragment that contains it is paused/stopped/destroyed.
Moreover, it detects when the video player is being covered (both partially or totally) by another view.
Upvotes: 1