Skip to content

Useful info

Pierfrancesco Soffritti edited this page Jun 30, 2018 · 7 revisions

The documentation has been moved in the readme of the project. This wiki is outdated.


Hardware acceleration

Is important that the Activity containing the YouTubePlayerView is hardware accelerated. This option is enabled by default, you won't have to do any changes in your app, unless you manually disabled hardware acceleration.

If you need to disable hardware acceleration in your application, you can enable it at the Activity level, as explained here.

Disabling hardware acceleration on the Activity containing YouTubePlayerView may result in some weird behavior. Those I have observed so far show a black image in the player, while the audio is playing normally.

Play YouTube videos in the background

With this library is easy to play YouTube videos when the app is not visible. In order to do that you simply have to not call youtubePlayer.pause() when the Activity is being paused or stopped.

Adding YouTubePlayerView as an observer to a lifecycle will automatically cause the player to pause the playback when the Activity/Fragment stops.

Therefore if you want your app to keep playing even when the Activity/Fragment is paused/stopped, don't register it as a lifecycle observer. But remember to manually call YouTubePlayerView.release() when the Activity/Fragment is destroyed.

Remember that this behavior is against YouTube terms of service, therefore if you decide to allow background playback you won't be able to publish your app on the Play Store.

Use this functionality only if you plan to build the app for your self or if you plan to distribute it through different channels.

minSdk

The minSdk of the library is 17. At this point it doesn't make much sense for new apps to support older versions of Android.

I'm not sure how WebView will behave on older versions of Android, but technically it should be possible to lower the minSdk. If you absolutely need to support older devices, I suggest you fork the library and lower the minSdk yourself.