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);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With