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

Android YouTube API Code only loads one video

$
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 = "xxxxx"    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

I call this video about 3 times, but only the video only loads one time. How can I fix this?


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>