Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YouTubePlayer not load Ad video with cueVideo()

I'm using YouTubePlayer to play YouTube video and use cueVideo(videoId) to load video, Which is working fine if video not contain Ad but video contain Ad then cueVideo(videoId) will not load video.

Also seen some discussion regards such problem which are suggested use loadVideo(videoId) instead of cueVideo(videoId) but as per my requirement i shown image until video not buffer and when video buffered hide image and show YouTubePlayer, So have to use cueVideo(videoId) instead of loadVideo(videoId).

Does any one having such issue ? thanks in advance for any suggestion or help.

Below is my code to load video :

 youTubePlayer.cueVideo(videoId);
like image 220
Haresh Chhelana Avatar asked Apr 18 '15 10:04

Haresh Chhelana


1 Answers

Preface: YouTube does not allow any View to be displayed over its video player.

My guess is that your "loading image", since it is displayed over the video player, is covering the ad that starts rolling for some videos. You can check this by reading the logs and keeping an eye for a warning thrown by the YouTube SDK.

I would suggest to use the YouTubePlayer.PlayerStateChangeListener callback, that offers the following methods:

abstract void onAdStarted()
abstract void onVideoStarted()
abstract void onLoaded(String videoId)

By using these methods, you can guarantee that your "loading image" is properly hidden just before the video or the ads starts playing.

like image 69
Sebastiano Avatar answered Nov 07 '22 03:11

Sebastiano