AUTOPLAY NO WEBVIEW2

DJROBERTOSC 18/05/2023 18:39:43
#501396
Olá galera, alguem já usou a ferramenta webview2 ? Estou usando mas quando abro um video do youtube ele não dá auto-play.
Alguem sabe como faço isso no VB.NET ? Obrigado pela atenção de todos. :)
KERPLUNK 18/05/2023 22:23:28
#501401
Resposta escolhida
Adicione o parâmetro "&autoplay=1" na URL. Deve funcionar
DJROBERTOSC 19/05/2023 20:25:13
#501411

Citação:

Adicione o parâmetro "&autoplay=1" na URL. Deve funcionar



Olá, agradeço fera, mas eu tentei isso e não funcionou. :)
DJROBERTOSC 02/06/2023 15:46:28
#501468
Galera consegui resolver, e adivinha quem me deu todo código ? o ChatGPT, hehehehe
Passo a seguir o procedimento caso alguem tenha o mesmo problema:
Button1 = Botão para abrir URL
Txtsite.Text = Textbox da URL
WebView21 = Nome do meu WebView2
Dentro do Form:
----------------------------------------------------------------------------------------------
Imports Microsoft.Web.WebView2.Core
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles BTsite.Click
WebView21.Source = New Uri(Txtsite.Text)
WebView21.CoreWebView2.ExecuteScriptAsync("document.querySelector('video').play();")
End Sub
Private Sub Txtsite_LostFocus(sender As Object, e As EventArgs) Handles Txtsite.LostFocus
If Txtsite.Text <> "" Then
Dim texto = Txtsite.Text.Substring(0, 3)
If texto <> "htt" Then
Dim novotexto = "http://" & Txtsite.Text
Txtsite.Text = novotexto
End If
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WebView21.Width = Me.Width - 30
WebView21.Height = Me.Height - 30
' Inicializa o controle WebView2
AddHandler WebView21.CoreWebView2InitializationCompleted, AddressOf WebView21_InitializationCompleted
WebView21.EnsureCoreWebView2Async(Nothing)
End Sub
Private Sub WebView21_InitializationCompleted(sender As Object, e As CoreWebView2InitializationCompletedEventArgs)
' Verifica se a inicialização foi concluída com sucesso
If e.IsSuccess Then
' Habilita o autoplay
WebView21.CoreWebView2.Settings.AreDefaultContextMenusEnabled = True
WebView21.CoreWebView2.Settings.AreDefaultScriptDialogsEnabled = True
WebView21.CoreWebView2.Settings.IsScriptEnabled = True
WebView21.CoreWebView2.Settings.IsWebMessageEnabled = True
WebView21.CoreWebView2.Settings.AreDevToolsEnabled = True
End If
End Sub
End Class
Tópico encerrado , respostas não são mais permitidas