YouTubePlayerSupportFragment shows Network error 400

只谈情不闲聊 提交于 2019-12-11 05:13:06

问题


YouTubePlayerSupportFragment shows Network error 400

I have created small demo to test YoutubeSupportFragment

 YouTubePlayerSupportFragment youtube_player_fragment = new YouTubePlayerSupportFragment();
        youtube_player_fragment.initialize(DEVELOPER_KEY, new YouTubePlayer.OnInitializedListener() {
            @Override
            public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
                if (null == youTubePlayer) return;
                if (!b) {
                    youTubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
                    youTubePlayer.cuePlaylist("zuf8A0udHrs");


                }
            }

            @Override
            public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {

            }
        });
        FrameLayout youtube_player_frame = (FrameLayout)findViewById(R.id.youtube_player_frame);
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.youtube_player_frame, youtube_player_fragment);
        fragmentTransaction.commit();

main.xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <FrameLayout
        android:id="@+id/youtube_player_frame"
        android:layout_width="match_parent"
        android:layout_height="190dp"/>
</LinearLayout>

Screenshot:


回答1:


Do you even have an internet connection ? Maybe try on another phone because there you are in Roaming mode maybe it doesnt work in there ?



来源:https://stackoverflow.com/questions/38696968/youtubeplayersupportfragment-shows-network-error-400

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