Android Question How to retrieve Youtube ID

samwoodsywoods

Member
Licensed User
Longtime User
www.youtube.com/watch?v=0xdZXOM_Otc

In the youtube library, to select which video you need the "0xdZXOM_Otc" portion of the url to direct the player to the video. How do I extract what comes after watch?v=

basically my aim is to use a webview to allow the user to select a video and the youtube library to play it, if there as an easier way to do it I am all ears
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
If you are using a webview, you can extract the video ID like this:
B4X:
Sub WebView1_OverrideUrl(Url As String) As Boolean

    Dim VideoToPlay  As String

    VideoToPlay = Url.Replace("http://www.youtube.com/watch?v=", "")	

...    			
	
End Sub

The result will be just the VideoID saved in the VideoToPlay variable.
 
Upvote 0

samwoodsywoods

Member
Licensed User
Longtime User
If you are using a webview, you can extract the video ID like this:
B4X:
Sub WebView1_OverrideUrl(Url As String) As Boolean

    Dim VideoToPlay  As String

    VideoToPlay = Url.Replace("http://www.youtube.com/watch?v=", "")

...   

End Sub

The result will be just the VideoID saved in the VideoToPlay variable.


Thank you! I'll give it a try
 
Upvote 0
Top