Private videoId As String
'Get YouTube VideoId from ...
videoId = ...
'Set up webview
UI_webview.Initialize("")
Page1.RootPanel.AddView(UI_webview, 0, 0, Page1.RootPanel.Width, Page1.RootPanel.Height)
Private no As NativeObject = UI_webview
no.RunMethod("setMediaPlaybackRequiresUserAction:", Array(False))
'Fly to YouTube website
UI_webview.LoadHtml( _
$"<!DOCTYPE html>
<html>
<head>
<style>body{margin:0px 0px 0px 0px;}</style>
</head>
<body>
<div id="player"></div>
<script> var tag = document.createElement('script');
tag.src = "https://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubePlayerAPIReady()
{
player = new YT.Player('player',
{
width:'${Page1.RootPanel.Width}',
height:'${Page1.RootPanel.Height}',
videoId:'${videoId}',
playerVars: { 'rel' : 0 },
events:
{
'onReady': onPlayerReady,
}
});
}
function onPlayerReady(event)
{
event.target.playVideo();
}
</script>
</body>
</html>"$)