Embed config is not supported in RemoteEmbeddedPlayer?

我只是一个虾纸丫 提交于 2021-02-20 06:15:50

问题


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.


回答1:


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.




回答2:


I faced the same issue ,it was due to the internet connection in the device was off so the solution is to connect the device to internet




回答3:


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.



来源:https://stackoverflow.com/questions/53087442/embed-config-is-not-supported-in-remoteembeddedplayer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!