YouTubePlayerSupportFragment 显示网络错误 400
YouTubePlayerSupportFragment shows Network error 400
YouTubePlayerSupportFragment 显示网络错误 400
我创建了小演示来测试 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>
截图:
你有互联网连接吗?
也许尝试另一个 phone,因为你在漫游模式下可能在那里不起作用?
YouTubePlayerSupportFragment 显示网络错误 400
我创建了小演示来测试 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>
截图:
你有互联网连接吗? 也许尝试另一个 phone,因为你在漫游模式下可能在那里不起作用?