Embed config is not supported in RemoteEmbeddedPlayer?
Asked Answered
T

4

17

Whenever I'm trying to open Youtube player in my app, onInitializationSuccess() function is always called. But it shows a blank screen.

First this error appears:

W/YouTubeAndroidPlayerAPI: Forcefully created overlay:affq@82a17f5 helper:Lazy@9b7098a view:null status: ....... {...}

and then:

E/YouTubeAndroidPlayerAPI: Embed config is not supported in RemoteEmbeddedPlayer.

Here is my code:

FragmentManager fragmentManager = ((AppCompatActivity)this.context).getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    Fragment  youtubeFragment = new YouTubePlayerSupportFragment();
    fragmentManager.beginTransaction().add(R.id.GlideLayout ,youtubeFragment).commit();


    utubevw = (YouTubePlayerSupportFragment) youtubeFragment;
    utubecontainer = imageLayout.findViewById(R.id.youtubecontainer);

    utubecontainer.setVisibility(View.VISIBLE);

    mOnInitializeListener = new YouTubePlayer.OnInitializedListener() {
        @Override
        public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
            youTubePlayer.cueVideo("_8kExcHqFi4");
            Log.i("youtube", "Successful");
        }
        @Override
        public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
            Log.i("youtube:Fail", youTubeInitializationResult.toString());
        }
    };
    utubevw.initialize(String.valueOf(R.string.googleapikey), mOnInitializeListener);

Searched everywhere, even posted in Github, but couldn't find a solution.

FYI - I don't want to use Webview to play Youtube.

Technique answered 31/10, 2018 at 15:54 Comment(4)
Have you checked this SO post? I think there still an open issue in github regarding this error.Dervish
Yup,checked that too.not found any solution.<br/> Also,i came to know,that it is not causing any kind of issue now,my youtube video was not appearing on screen only because there are two youtube fragments created.I removed the other one,and it started showingTechnique
I'm seeing this issue only in the signed release version of my app, but it works as expected in debug build.Hernia
now i have this error and i can not fix thisWayne
C
4

I had the same problem just now and i was able to solve it by removing all possible overlaying views. I had a FAB just closely overlaying the youtube fragment. After moving the FAB away the error was fixed.

Chalcedony answered 7/11, 2018 at 16:21 Comment(1)
Peter, thank you very much! You saved me from stupid refactoring!Identification
K
0

Try using youTubePlayer.loadVideo(" ") instead of youTubePlayer.cueVideo(" ") to auto play the video when the fragment is started. According to the docs, if you use the cueVideo() function, you need to call play() or it does not download any of the video stream. Whereas the loadVideo() auto plays the video.

Karakalpak answered 30/7, 2020 at 11:18 Comment(3)
Make sure you're giving the correct ID of the video you want to play instead of the whole URL in .cueVideo() or .loadVideo(). Are you using regex to get the video ID?Karakalpak
Can you show your regex? If you want, use this instead, String pattern = "(?<=watch\\?v=|/videos/|embed/)[^#&?]*";Karakalpak
sure will try this one. ThanksCheyennecheyne
Y
0

I tried the answer of @PeterOla, it worked for sometime but after sometime the error came back, and after hours of struggle, i found that i had to parse just the key url (without the youtube/) in the youTubePlayer.cueVideo(""), and it worked well for me.

Yanina answered 4/4, 2021 at 9:25 Comment(0)
T
0

I was looking for a solution but my mistake was that I was passing the full url

incorrect

youTubePlayer.cueVideo("https://www.youtube.com/watch?v=_8kExcHqFi4");

correct

youTubePlayer.cueVideo("_8kExcHqFi4");
Thaumaturge answered 8/4, 2023 at 0:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.