YouTube video player

If you are working with Youtube on your website, you can easily add Spott's interactive layer by adding a script to your existing implementation.

Your current video publishing process is not affected, which means you publish your videos first and add the interactive layer independently.

Our Youtube integration works by adding a code snippet to your website where your video is shown, and by adding the youtube video id in Spott.

 

1. Using Spott video ID

If you have access to your own website, this is probably the easiest option. If your website is managed by someone else, it might be best to take a look at the next solution by using an External ID

Before you start these steps, make sure you've uploaded your video to the Youtube platform and added it to your website already.

Step 1: Upload your video to Spott and make it interactive

You'll add interactive elements to your video in the Spott Studio. In order to do that, you should upload your video to the Spott platform.

Log into Spott and go to the projects page, upload your video, and make it interactive.

We have a full step-by-step guide for you if you haven't learned how to do this already.

Step 2: Put this code snippet on your website

Go to your website and put in this code snippet. Leave this page open as you still need to make some changes in step 3.

 

JS Version:

<script src="https://static.spott.ai/videoplayer/js/spott.youtube.js" /></script>

<div id="youtube_player_id_here"></div>
<script> function onYouTubeIframeAPIReady () { const player = new YT.Player('youtube_player_id_here', { videoId: 'youtube_video_id_here', width: '620px',
events: {
'onReady': loadSpottLayer
} playerVars: { 'autoplay': 1, 'controls': 1, 'autohide': 0, 'wmode': 'opaque', 'origin': '' }}); function loadSpottLayer() {
if(!player.spottLoaded){
if (window.initSpottYouTube) {
initSpottYouTube(player, {
videoId: "spott_video_id_here"
});
player.spottLoaded=true;
} else {
setTimeout(loadSpottLayer, 500);
}
}
} }; </script> <script src="https://www.youtube.com/iframe_api"></script>

iFrame Version:

<script src="https://static.spott.ai/videoplayer/js/spott.youtube.js" /></script>

<iframe width="560" height="315" id="youtube_player_id_here" src="https://www.youtube.com/embed/youtube_video_id_here?enablejsapi=1&origin=https://yourwebsite.com" title="YouTube video example" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<script> function onYouTubeIframeAPIReady () { const player = new YT.Player('youtube_player_id_here', {
events: {
'onReady': loadSpottLayer
} }); function loadSpottLayer() {
if(!player.spottLoaded){
if (window.initSpottYouTube) {
initSpottYouTube(player, {
videoId: "spott_video_id_here"
});
player.spottLoaded=true;
} else {
setTimeout(loadSpottLayer, 500);
}
}
} }; </script> <script src="https://www.youtube.com/iframe_api"></script>

The script acts as a bridge between your player and Spott. To set this up, enter these parameters:

  • A selector player which targets the instance of your video player.
  • videoId inside initSpottYouTube section is the Spott ID of the video currently initialized, which we'll show you how to get in the next step.
  • make sure to add "enablejsapi=1" to your youtube video url if you use the iFrame version!

Step 3: Get the Spott video ID

When you have uploaded your video, go to the Spott Studio where you can copy the video ID.

Look at the URL and copy the ID, this is the last part of the URL before the ? symbol. You can paste this in the videoId parameter.

 

Screenshot_2022-10-04_at_10.59.50.png

 

Paste the Spott video ID you just copied and place in the script on your website.

Awesome, your Youtube video should now have an interactive layer!

 

Integration with the Youtube Player

Before you start these steps, make sure you've uploaded your video to the Youtube platform and added it to your website already.

Step 1: Upload your video to Spott and make it interactive

You'll add interactive elements to your video in the Spott Studio. In order to do that, you should upload your video to the Spott platform.

Log into Spott and go to the projects page, upload your video, and make it interactive.

We have a full step-by-step guide for you if you haven't learned how to do this already.

 

Step 2: Put this code snippet on your website

Add the following script to each page where you want Spott's layer to appear over a YouTube video:

<script src="https://static.spott.ai/videoplayer/js/spott.youtube.js"/></script>
<script src="https://www.youtube.com/iframe_api"></script>

Every time a new video gets initialized in the player, you can trigger its interactive layer with the following snippet:

JS Version:

<script src="https://static.spott.ai/videoplayer/js/spott.youtube.js" /></script>

<div id="youtube_player_id_here"></div>
<script> function onYouTubeIframeAPIReady () { const player = new YT.Player('youtube_player_id_here', { videoId: 'youtube_video_id_here', width: '620px',
events: {
'onReady': loadSpottLayer
} playerVars: { 'autoplay': 1, 'controls': 1, 'autohide': 0, 'wmode': 'opaque', 'origin': '' }}); function loadSpottLayer() {
if(!player.spottLoaded){
if (window.initSpottYouTube) {
initSpottYouTube(player, {});
player.spottLoaded=true;
} else {
setTimeout(loadSpottLayer, 500);
}
}
} }; </script> <script src="https://www.youtube.com/iframe_api"></script>

The script acts as a bridge between your player and Spott. To set this up, set these parameters:

  • A selector player that targets the instance of your video player.

 

Step 3: Add the external id on Spott

While you're still in the Studio, click on the projects tab:

 

Screenshot_2022-09-22_at_11.30.46.png

 

 

In this modal, you should see "External source", select "Youtube". In the ExternalID field you can enter your Youtube id.

For external id, this is the ID of your Youtube video. This can be found at the end of your Youtube video URL, highlighted in bold:

https://www.youtube.com/watch?v=dQw4w9WgXcE

Click save to continue. Now you're all set!

 

Was this article helpful?
1 out of 4 found this helpful

Comments

0 comments

Article is closed for comments.