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.
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:
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.
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.
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.