Android Question Get Youtube Video ID ,Webview

pemulanih

Member
dear master,
i want to get youtube video id from URL webview, its works ..but not changed automaticly.. i have to click any link on webview to show on label
this is my code: CMIIW
B4X:
Sub Globals
    Private WebView1 As WebView
    Private Label1 As Label
    Private Label2 As Label
    Private Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    WebView1.LoadUrl("https://m.youtube.com")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub vid(Text As String) As String
    Return Text.SubString(Text.LastIndexOf("=") + 1)
End Sub

Sub WebView1_PageFinished (Url As String)
    Dim idlist As List = Regex.Split("=var", Url)
    For Each ytid As String In idlist
        If ytid.Length > 0 Then
            Label1.Text=(vid(ytid))
        End If
    Next
End Sub

any suggestion?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0
Top