This is my main 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;
}
}
and here is my xml file
<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>
I am getting youtube video, but after playing it for 1 second, it gives me error of "UNAUTHORIZED_OVERLAY".
I have searched a lot and everyone is saying we can not add another view on it, but as you can see there is just fragment in my xml, nothing else.