Android Question Current Approach to Playing YouTube Videos

DawningTruth

Active Member
Licensed User
I have been searching the forum to find out what the current methods are for playing YouTube videos. It seems like thee is a choice between WebView, Erel's YouTube Player and Exoplayer.

Which method is currently the best approach for playing YouTube Videos?
 

DawningTruth

Active Member
Licensed User
As far as I remember it is difficult if not impossible to get the direct link which is required for playing the video with ExoPlayer.
YouTube library is probably the best option.
Thx Erel, as always you are extremely helpful :).

In terms of my future need to migrate my app to iPhone, are their similar libraries on that side?
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Upvote 0

DawningTruth

Active Member
Licensed User
You can get the direct links using this library
https://www.b4x.com/android/forum/threads/youtube-dl-extract-direct-urls.100793/
And then Exoplayer should be able to play the video.
However I would not recommend using that library in an app that you publish on Google Play Store for obvious reasons.
Thx Moster,

As the app will be public facing and will utilise Google's services I would prefer to refrain from any TOS violation risks.

Do any of your libraries allow a person to extract the thumbnail of a Video?
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
No idea - I have never worked with YouTube except for the wrapper I linked to (which I believe is also able to extract a thumbnail)..
Sorry.
 
Upvote 0

valentino s

Active Member
Licensed User
Longtime User
Please take care of https://developers.google.com/youtube/android/player/ . Google removed my app due to use of youtube embeds in a webview. I removed the embeds, the app is again in the store.

Now I'm looking for a different method (no more a simple embed).

"YouTube library is probably the best option." the library is dated 2013, I guess if it is compliant with Youtube's Tos.

Perhaps the solution is provided in this discussion, I hope it can help someone: https://www.b4x.com/android/forum/threads/class-b4x-youtube-v3.58550/page-4#post-652709
 
Last edited:
Upvote 0

DawningTruth

Active Member
Licensed User
Please take care of https://developers.google.com/youtube/android/player/ . Google removed my app due to use of youtube embeds in a webview. I removed the embeds, the app is again in the store.

Now I'm looking for a different method (no more a simple embed).

"YouTube library is probably the best option." the library is dated 2013, I guess if it is compliant with Youtube's Tos.

Perhaps the solution is provided in this discussion, I hope it can help someone: https://www.b4x.com/android/forum/threads/class-b4x-youtube-v3.58550/page-4#post-652709
Thx Valentino, this indeed is a cause for concern as that was the approach I settled on. I just wish there were simple ways to do basic things, without Google making our lives more difficult. I will look up your solution in the link.
 
Upvote 0

DawningTruth

Active Member
Licensed User
Thx Valentino, this indeed is a cause for concern as that was the approach I settled on. I just wish there were simple ways to do basic things, without Google making our lives more difficult. I will look up your solution in the link.
Ok, I remember this one now. It lists videos but does not play them. The ideal solution which I have not seen is a simple embedded video player that can play from a YouTube url like the embedded YouTube in Webview solution.
 
Upvote 0

valentino s

Active Member
Licensed User
Longtime User
Upvote 0

DawningTruth

Active Member
Licensed User
This was my solution I removed. An example: https://www.pregaognigiorno.it/video/index.php
I see. I did notice that your video is larger than the screen which may affect usability. I managed to get mine fitting the screen, but it used some complicated javascript which basically detected the screen width and then adjusted the size of the video accordingly.

I wonder if the video size issue may have been Google's reason for removing the app, or is it just they want developers to use the Android API?

PS: See my other thread on this topic:

https://www.b4x.com/android/forum/threads/youtube-android-player-api.106198/
 
Upvote 0

valentino s

Active Member
Licensed User
Longtime User
Upvote 0
Top