Home > Forum > Plugins > Embed a videoplayer

Embed a videoplayer
0

MVP

Hi,

You can use html attribute to embed the player.
As for video status tracking, perhaps with js you can get that, but I don't know. Out of curiosity, I'll try to check it out, unless someone provides a ready-made solution beforehand.

Regards

--Edit , The script will display an alert when the video ends, you can insert another script ,

<!DOCTYPE html>
<html>
<head>
<title>Youtube Player</title>
</head>
<body>
<iframe id="youtube-player" width="800" height="450" src="https://www.youtube.com/embed/Ha6y3JbayB4?enablejsapi=1" frameborder="0" allowfullscreen></iframe>

<script>
var player;

function onYouTubeIframeAPIReady() {
player = new YT.Player('youtube-player', {
events: {
'onStateChange': onPlayerStateChange
}
});
}

function onPlayerStateChange(event) {
if (event.data === YT.PlayerState.ENDED) {
// Show alert when the video ends
alert('End of video :) ');
}
}
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
</script>
</body>
</html>