Rav*_*avi 3 youtube android fragment
这是我的主要片段
public class VirtualClassFragment extends Fragment// implements YouTubePlayer.OnInitializedListener
{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.fragment_virtual_class, container, false);
YouTubePlayerSupportFragment pl = (YouTubePlayerSupportFragment) getChildFragmentManager().findFragmentById(R.id.youTubePlayerFragment);
pl.initialize("<API_KEY>", new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
youTubePlayer.cueVideo("nGyqHoKa7yk");
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
}
});
return v;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 xml 文件
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:name="com.google.android.youtube.player.YouTubePlayerSupportFragment"
android:id="@+id/youTubePlayerFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
我正在获取 YouTube 视频,但播放 1 秒后,出现“UNAUTHORIZED_OVERLAY”错误。
我搜索了很多,每个人都说我们不能在上面添加另一个视图,但正如你所看到的,我的 xml 中只有片段,没有其他东西。
| 归档时间: |
|
| 查看次数: |
3108 次 |
| 最近记录: |