I'm implementing YouTube Android Player API and trying to add YouTubePlayerView to my AppCompatActivity accorting to this manual, but get an exception:
Caused by: java.lang.IllegalStateException: A YouTubePlayerView can only be created with an Activity which extends YouTubeBaseActivity as its context.
YouTubeBaseActivity extends Activity (not AppCompatActivity). I checked sample project on GitHub and noticed that the latest commit was 3 years ago, so I suppose that this library is deprecated especially given that it's distributed as .jar file only. My question is next: where can I find source code of this library to fix YouTubeBaseActivity or what should I use instead of it? Or maybe you can suggest me better way to play YouTube video inside my app (without Intent)? Thanks.
The alternative would be to use YouTubePlayerFragment
.
A fragment that contains a YouTubePlayerView. Using this fragment is the preferred way of playing YouTube videos because your activity does not need to extend an activity provided by the library, as is the case with using the YouTubePlayerView directly.
See if this helps you:
https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubePlayerFragment