B
B
BackSpark2015-12-30 23:06:51
Facebook
BackSpark, 2015-12-30 23:06:51

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

1 answer(s)
A
Anton Robul, 2016-01-06
@anton_slim

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() {
    // здесь пишем код функции по окончанию просмотра видео
}

in the case of the specified Your site, the window is shown in the .videoWindowContent layer in which two sharing buttons are defined:
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 question

Ask a Question

731 491 924 answers to any question