UPDATE 1.22 ( "change" parameters call get_video_info  )
BUGFIX UPDATE 1.21 ( "change" Format File json get_info for B4i )
BUGFIX UPDATE 1.20 ( "change" API Youtube )
see:
We all know the excellent ExoPlayer, too bad it doesn't load videos from youtube links. With this Library (B4A, B4i, B4J) it is possible to view the direct youtube link on both ExoPlayer, VideoPlayer and WebView.
The code is very simple:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			BUGFIX UPDATE 1.21 ( "change" Format File json get_info for B4i )
BUGFIX UPDATE 1.20 ( "change" API Youtube )
see:
Hi All.[RESOLVED] get_video_info YouTube
Hi All. it seems that the youtube api on get_info have changed .... when calling the same it returns 404 (HTTP ERROR 404 Page not found) https://www.youtube.com/get_video_info?&video_id=wsSFkyRil_g Has anyone encountered the problem ? Thanks Marcowww.b4x.com
We all know the excellent ExoPlayer, too bad it doesn't load videos from youtube links. With this Library (B4A, B4i, B4J) it is possible to view the direct youtube link on both ExoPlayer, VideoPlayer and WebView.
The code is very simple:
			
				B4X:
			
		
		
		Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private player1 As SimpleExoPlayer
End Sub
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Dim DL As DLinkYouTube
    Dim ke_y As String = $"YOUR API KEY YOUTUBE"$
    Private B4XImageView1 As B4XImageView
    Private Button1 As Button
    Private SimpleExoPlayerView1 As SimpleExoPlayerView
End Sub
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
End Sub
Private Sub Button1_Click
    DL.Initialize(ke_y)
    'Put ID YouTube
    Wait For(DL.DirectLinkYT($"EynXt2GVpTg"$)) Complete (Result As Map)
    'Log("Result: " & Result)
    Dim state As String =  Result.Get("state_movie")
    Dim link_movie As String = Result.Get("link_movie")
    Dim pic As String = Result.Get("link_immagine")
    Dim movie_mute As String = Result.Get("link_movie_mute")
    If state = "UNPLAYABLE" Then
        Log("Result: Video not available")
    Else
        'Load DL Youtube
        'Log($"${link_movie}"$)
        player1.Initialize("player")
        Dim sources As List
        sources.Initialize
        sources.Add(player1.CreateUriSource($"${link_movie}"$))
        '.....
        player1.Prepare(player1.CreateListSource(sources))
        SimpleExoPlayerView1.Player = player1
        player1.Play
        'Load Imagine YouTube
        DownloadImage(pic, B4XImageView1)
    End If
End Sub
'Per Caricare immagine singola
Sub DownloadImage(Link As String, iv As B4XImageView)
    Dim job As HttpJob
    job.Initialize("", Me) 'note that the name parameter is no longer needed.
    job.Download(Link)
    Wait For (job) JobDone(job As HttpJob)
    If job.Success Then
        iv.Bitmap = job.GetBitmap
    End If
    job.Release
End SubAttachments
			
				Last edited: 
			
		
	
							 
				 
 
		 
 
		 
 
		 
 
		 
			 
 
		 
 
		 
 
		 
					
				 
						
					 
 
		 
 
		 
 
		