If you decide to set it to false you should also disable enableAutomaticInitialization and manage network events on your own. It is useful to have this attribute set to true so that if the connection drops while the player is initializing YouTubePlayerView will be able to resume the initialization automatically once the network is back. If false, you will be responsible for handling network events. If true, YouTubePlayerView handle network events by registering a NetworkReceiver. You may want to set it to false only if you need to initialize the view using IFramePlayerOptions. In general it makes sense to leave this attribute to true. If false, you will have to initialize YouTubePlayerView programmatically. If true, YouTubePlayerView will take care of its initialization. If videoId is not set, this attribute is useless, therefore if it is set to true YouTubePlayerView will throw an exception.ĪutoPlay won't work if YouTubePlayerView is not added as a LifecycleObserver of its parent Activity/Fragment. If false, the player will wait for user input before playing the video provided with videoId. If true, the player start playing the video provided with videoId without waiting for user input. In fact, even if you set the attribute it is still possible to play other videos programmatically. In general you should use this attribute if you want your player to play only one video. If not set, the player won't automatically play. If set, the player will automatically start playing the video. This attribute expects a String, which is the id of a YouTube video. Everything can also be done programmatically. If you add the view to your XML layout you have the possibility to set a few custom attributes, to customize the view's look and behavior. If the height of the View is set to wrap_content, the View will automatically have an aspect ratio of 16:9, to match the aspect ratio of most YouTube videos. YouTubePlayerView youTubePlayerView = new YouTubePlayerView( this) It's all you need to play YouTube videos in your app.Īdd this to your module level adle file. The core module contains the YouTube Player. The minimum API level supported by this library is API 17. The Gradle dependency is available via MavenCentral. □ If you want to know when a new release of the library is published: watch this repository on GitHub. Download apk of chromecast-sender sample app.□ You can also download and install the apks of both sample apps. Go to source code of chromecast-sender sample app.□ Both the core module and the chromecast module have a sample app, to provide examples of usage of the libraries. This is issue has nothing to do with the library itself, but I figured it may be useful knowledge for many of you considering to use it. If you follow the instructions in the documentation, the library will automatically handle this for you.Īlso remember when publishing your app on the PlayStore to write title and description in a way that makes it obvious that your app doesn't have any affiliation with YouTube (the company). That said how you use the library matters, be sure to play videos only when the player is visible. You can see here how this is also the official way of playing YouTube videos on iOS. Therefore it is 100% compliant with terms of service. The library uses YouTube's own web player to play videos. This, added to its limited options for customization and lack of Chromecast support, lead me to the development of this open source library.Ī lengthier explanation to why you may want to consider using an alternative to the official YouTube player is written in this Medium post.Ī list of published apps that are using this library: ( let me know if you want to add your app to this list)ĭoes this library breaks YouTube terms of service? I personally found it quite unreliable and therefore impossible to use in production. Unfortunately this library is quite buggy ( some bugs are 5+ years old) and has receive no updates in years. The official library provided by Google to integrate YouTube videos in Android apps is the YouTube Android Player API. ![]() ![]() This library also provides a Chromecast YouTube player, that you can use to cast YouTube videos from your app to a Chromecast device. However this should be done with cuation, as altering the UI of the IFrame player might break YouTube's terms of service. The UI can be completely replaced with a custom UI. ![]() The UI of the player is 100% customizable. Therefore the YouTube app is not required on the user's device and there are no issues with YouTube Terms of Service. The library is a wrapper over the IFrame Player API, which runs inside of a WebView. It provides a simple View that can be easily integrated in every Activity/Fragment. Android-youtube-player is a stable and customizable open source YouTube player for Android.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |