Answer the question
In order to leave comments, you need to log in
How to make sharing links at the end of the video?
On this page there is a YouTube video marketium.ru/malyshka-plakala-navzryd-3 if you watch it to the end, a window will appear with the VK and FB repost buttons. How to implement something like this?
Answer the question
In order to leave comments, you need to log in
To do this, you need to connect the video using the youtube JS API and catch the end of view event, this is done as follows:
<div id="player"></div>
<script src="http://www.youtube.com/player_api"></script>
function onYouTubePlayerAPIReady() {
player = new YT.Player("player", {
height: "450",
width: "800",
playerVars: {
'start': 00,
'end': 00,
'theme': 'light',
'rel': 0
},
videoId: "FH3hIggyJ-U",
events: {
onStateChange: onPlayerStateChange
}
})
}
function onPlayerStateChange(a) {
if (a.data === 0) {
videoEnded();
}
};
function videoEnded() {
// здесь пишем код функции по окончанию просмотра видео
}
function videoEnded() {
if ($(window).width() < 728) {
$(".videoWindowContent").css("marginTop", $("#player").height() / 2 - $(".videoWindowContent").height() / 2);
}
$(".videoWindowContent").stop().fadeIn(300)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question