How to use Youtube Player with modern interface in Android using YoutubePlayerSupportFragment

I am trying to use Youtube Player in my android application. It shows the old outdated user interface for the player, but in the samples it shows the modern user interface. The only difference between the two applications is to use YoutubePlayerSupportFragment instead of YoutubePlayerFragment. This is because I am using AppCompatActivity for the Material Theme on devices with a pre-leoptype.

I get the following statement in the logs:

W/YouTubeAndroidPlayerAPI﹕ Cannot load modern controls UI. Upgrade to the latest version of the Android YouTube API. 

How to overcome this problem? I need a modern interface using Appcompat and YoutubePlayerSupportFragment

+7
android youtube youtube-api
source share
2 answers

I found something that worked for me.

Set this before super.OnCreate () in the action your fragment is in:

getLayoutInflater () setFactory (this) ;.

+9
source share

I assume YouTube APIs are not yet updated .

Consider this:

  • The Android Player API for Android (found here ) is just an empty remote View that refers to the official YouTube application that needs to be installed on the device to work.
  • the YouTube app is now minSdk 15, which means Fragment supported based
  • as you mentioned, everything works with YouTubePlayerFragment , but not with YouTubePlayerSupportFragment

I believe that the YouTube SDK can directly import the player’s representation from the YouTube application using modern user interface controls. However, Fragment support requires more action on the part of the SDK, an action that remains to be done as an update.

TL; DR

It’s best to expect YouTube’s APIs to be updated to a newer version.


EDIT

It looks like the YouTube SDK has just been updated to 1.2.2 ! Up here to download it.

+4
source share

All Articles