Search code examples
javaandroidyoutubeyoutube-apiandroid-youtube-api

Android application can't launch some videos from YouTube


I try to play video from YouTube in the application. Some videos are launching, but for some I get an error 'Video is not available'! I have no idea what is the difference!

My code:

    mOnInitializedListener = new YouTubePlayer.OnInitializedListener() {
            @Override
            public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
                Log.d(TAG, "onClick: Done initializing");
                
                //youTubePlayer.loadVideo("G5ws-ztZ0xU"); // <-- this is working!
                 youTubePlayer.loadVideo("K0PtPOtMCy4&t=9s"); // <-- this is not working!

            }

enter image description here


Solution

  • The thing is that you need to take the video id from the 'Share' window:

    enter image description here