B4A Library YouTube library

The YouTube library allows you to play YouTube videos inside your application.

It is based on a new service provided by Google. Note that this service is considered experimental.

This library is supported by Android 2.2+. It requires YouTube app v4.2.16 which is currently the latest version. You can update YouTube from Google Play.

SS-2013-01-03_11.57.47.png


Setup instructions
1. Download the native library: https://developers.google.com/youtube/android/player/downloads/
2. Copy libs\YouTubeAndroidPlayerApi.Jar from the zip file to Basic4android libraries folder.
3. Download the attached library, unzip it and copy the files to the libraries folder.
4. Get a developer key. Follow these instructions: https://developers.google.com/youtube/android/player/register
Note that you can leave the SHA1 field empty.

Example code:
B4X:
Sub Process_Globals

End Sub

Sub Globals
   Dim YouTube As YouTubeStandalonePlayer
End Sub

Sub Activity_Create(FirstTime As Boolean)
   YouTube.Initialize("YouTube")
   If YouTube.CheckPlayerSupported <> "SUCCESS" Then
      Msgbox("YouTube service not available: " & CRLF & YouTube.CheckPlayerSupported, "")
   Else
      Activity.AddMenuItem3("Play Video", "PlayVideo", Null, True)
   End If
End Sub
Sub PlayVideo_Click
   YouTube.StartVideo("AIzaSyxxxxxxxx-xxxx-xxxxxxxxxxxx", _
      "0xdZXOM_Otc", 0, False, True)
End Sub

Sub YouTube_Result (Message As String)
   Log("Result = " & Message)
End Sub

Important, YouTube service will not work if the Version Name field is empty.

The player can play in full screen or in lightbox mode. The above screenshot is for lightbox mode.
 

Attachments

  • YouTube.zip
    3.5 KB · Views: 2,592

JackKirk

Well-Known Member
Licensed User
Longtime User
Erel,

I did a bit of a google - it appears that the YouTube app is a "system app" - you don't actually uninstall it - you disable it - which was not very clear to me when I did it.

I'm guessing this means whatever low level libraries that the B4A YouTube library is dependant on are still there - and therefor it still works.

I guess it also means I don't have to tell the user of my app that he needs to install the YouTube app - unless he has a rooted device and has managed to really delete it - in which case he can look after himself.

Well I've learnt something - you probably haven't:)

Sorry for using your valuable time and thanks for your speedy response...
 

rafaelbr20

Member
Licensed User
Longtime User
Hi Everyone,

I'm having some problems to play some videos.

ERROR: "An error occurred touch to retry

Videos ID's i can Play
6h7zBG8m3vM
1wTOoharCeg
b_7CERpi3jc

Videos ID's having problem to play
jiN8M8vjgvQ
QZmPbW8W0TU
-FCgoCeWIK0

There is some video blocking from some channels or something like that ?

Thanks
 

Attachments

  • WhatsApp Image 2017-03-09 at 23.08.30.jpeg
    WhatsApp Image 2017-03-09 at 23.08.30.jpeg
    35.5 KB · Views: 328

MarcoRome

Expert
Licensed User
Longtime User
Hi Everyone,

I'm having some problems to play some videos.

ERROR: "An error occurred touch to retry

Videos ID's i can Play
6h7zBG8m3vM
1wTOoharCeg
b_7CERpi3jc

Videos ID's having problem to play
jiN8M8vjgvQ
QZmPbW8W0TU
-FCgoCeWIK0

There is some video blocking from some channels or something like that ?

Thanks
Try this new library EXOPLAYER by @Erel
 

MarcoRome

Expert
Licensed User
Longtime User
Hi Everyone,

I'm having some problems to play some videos.

ERROR: "An error occurred touch to retry

Videos ID's i can Play
6h7zBG8m3vM
1wTOoharCeg
b_7CERpi3jc

Videos ID's having problem to play
jiN8M8vjgvQ
QZmPbW8W0TU
-FCgoCeWIK0

There is some video blocking from some channels or something like that ?

Thanks
I tried this: jiN8M8vjgvQ and work

Screenshot_20170310-071311.jpg
 

hanyelmehy

Active Member
Licensed User
Longtime User
Can we have more control on the player , For Example hide youtube icon ,Removing elements from within the YouTubePlayerView
 

hanyelmehy

Active Member
Licensed User
Longtime User
No. Nothing is configurable.
Thank you for your answer
as i read Starting from version 4.1.7 (android-youtube-player) you can remove all the controls at the bottom, individually.
for example:
youTubePlayerView.getPlayerUIController().showCurrentTime(false);
youTubePlayerView.getPlayerUIController().showSeekBar(false);
youTubePlayerView.getPlayerUIController().showDuration(false);
youTubePlayerView.getPlayerUIController().showYouTubeButton(false);
youTubePlayerView.getPlayerUIController().showFullscreenButton(false);

can we apply that on current library ,or can you please share library code
Thank you
 

DonManfred

Expert
Licensed User
Longtime User
any other code use YouTubePlayerView instead of YouTubeStandalonePlayer
YouTubePlayerView give more control on player
the library is based on YouTubeStandalonePlayer.
For YouTubePlayerView you need to write a wrapper/library first.
 

piyushvekariya025

Member
Licensed User
Longtime User
Hi,
Is there any change occurs in this library?
I use it in my own app to embed my youtube channel video.
But since last two or three days, there is not play youtube video more than one time. Video paused automatically. and not play after then.
please inform me for any update.
 
Top