7

I am trying to use Youtube Player in my android app. It is showing a old outdated UI for the player but in the samples its showing a modern UI. The only difference between the two apps is I am using YoutubePlayerSupportFragment instead of YoutubePlayerFragment. This is because i am using AppCompatActivity for Material Theme in pre lollipop devices.

I am getting the below statement in 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 the modern UI using Appcompat and YoutubePlayerSupportFragment

Kalyan
  • 612
  • 6
  • 20

2 Answers2

9

I found something that worked for me.

Set this before super.OnCreate() in the Activity your fragment is currently on:

getLayoutInflater().setFactory(this);

Arnold Balliu
  • 1,099
  • 10
  • 21
  • Awesome find! No idea why this is needed or what it does, but it worked! Google, if you are reading this, update the docs! – Jawnnypoo Mar 02 '16 at 03:01
  • I'm assuming that if you use Support libs the default factories used are old. They're kinda forced and then when you explicitly state the factory you wanna use, it overrides that. I haven't read much about factories or what they actually do so this is pure assumption. – Arnold Balliu Mar 02 '16 at 03:37
4

My guess is that the YouTube APIs have yet to be updated.

Consider this:

  • the YouTube Android Player API (found here) is just a bunch of remote Views that link to the official YouTube application, that needs to be installed on the device for it to work
  • the YouTube app is now minSdk 15, meaning that Fragments are natively supported
  • as you mentioned, everything works with YouTubePlayerFragment, but not with YouTubePlayerSupportFragment

I believe that the YouTube 'SDK' can directly import the player view from the YouTube app, taking advantage of the modern UI controls. However, support Fragments require more actions on the SDK side, actions which are yet to be taken in the form of an update.

TL;DR

Your best bet is waiting for the YouTube APIs to be updated to a newer version.


EDIT

Looks like the YouTube SDK has just been updated to 1.2.2! Head over here to download it.

Sebastiano
  • 12,289
  • 6
  • 47
  • 80