Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3718

YouTubeAndroidPlayerAPI only loads once

$
0
0
private lateinit var youtubePLayerInit: YouTubePlayer.OnInitializedListenerprivate fun openTrailer(videoId: String) {    val dialog = Dialog(this)    val trailerDialogBinding =  DialogTrailerBinding.inflate(layoutInflater)    dialog.setContentView(trailerDialogBinding.root)    dialog.setCanceledOnTouchOutside(false)    val youtubeApiKey = "xxxxxxxxxxxxxxxxxxxxxxx"    youtubePLayerInit = object: YouTubePlayer.OnInitializedListener {        override fun onInitializationSuccess(            p0: YouTubePlayer.Provider?,            p1: YouTubePlayer?,            p2: Boolean        ) {            p1?.loadVideo(videoId)        }        override fun onInitializationFailure(            p0: YouTubePlayer.Provider?,            p1: YouTubeInitializationResult?        ) {            Toast.makeText(applicationContext, "Video Failed to Load", Toast.LENGTH_SHORT).show()        }    }    trailerDialogBinding.vvMovieTrailer.initialize(youtubeApiKey, youtubePLayerInit)    dialog.show()    trailerDialogBinding.btnExit.setOnClickListener {        dialog.dismiss()    }}

Thing is that video loads only one time, when I reload the video then dismissing the dialog. It doesn't load, then after like 3 or 4 times of loading, the app crashes with the errors of :

E/YouTubeAndroidPlayerAPI: Embed config is not supported in RemoteEmbeddedPlayer.E/YouTubeAndroidPlayerAPI: Error screen presenter should be present

It doesn't even show the ad failed to load. which is supposed to show when the video fails to load.


Viewing all articles
Browse latest Browse all 3718

Latest Images

Trending Articles



Latest Images