I have an app with fragments and inside those fragments I have frame layout into which I add YouTubePlayerSupportFragment. But when I click full screen then this exception is thrown:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.xxx/com.example.xxx.MainActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f040039 (com.example.xxx:id/frame_youtube) for fragment YouTubePlayerSupportFragment{4282a068 #11 id=0x7f040039}
Or you can just disable it by 1 line:
I faced the same issue and found a way to handle it that worked for me. In the
OnInitializedListener()
for the fragment, I do this:And I still got an error since I used the YouTubeStandalonePlayer to handle my full screen, so I solved that by calling
in my
OnPause()
for the activity. Just remember you won't come back to where you left off if your user hits the back button. You could also send the user to the YouTube app through an intent, this did not require thefinish()
in OnPause when I tested it, but did not suit my needs as well as the standalone player.Edit: If you want to remove the full-screen button, you can also just set the player style like this: