Varsha P
Varsha P

Reputation: 311

Video in YouTubePlayerView pausing after 2 sec in android phones

I am loading video in YouTubePlayerView(in android device). Initially it plays for 2 seconds and stops by showing play button on it. If again I press play button , video plays for 2 sec and get paused.

Upvotes: 2

Views: 1444

Answers (3)

jerrin george
jerrin george

Reputation: 35

Add margins to the wrapper view around the youtube view,I did this and added margin both vertically and horizontally and the error was fixed.

Upvotes: 0

Mike Miller
Mike Miller

Reputation: 3507

I was getting the same behavior and the error "UNAUTHORIZED_OVERLAY," but this actually had nothing to do with the solution I eventually found. I wasn't overlaying the video with anything, and had the padding was 0. My problem was that the targetSdkVersion was set to 26. I reduced it to 19 and it works now. This took forever to track down, so hopefully this will save someone else some time.

tl;dr: Reduce the targetSdkVersion in your app's build.gradle to 19

Upvotes: 1

Sasi Kumar
Sasi Kumar

Reputation: 13348

Make sure the size of the YoutubePlayer view is atleast 200x110 dp like descriped in the Youtube API documentation. Sounds like it doesn't meet those requirements when in landscape mode.

Youtube API documentation

https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubePlayerView

Upvotes: 0

Related Questions