"You must be using the iframe method of embedding videos"
Opened this issue · 2 comments
Joostan commented
Does this mean i can use the: YouTube IFrame Player API?
i.e.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('mydiv', {
height: '390',
width: '640',
videoId: 'XXXXXXX',
});
}
Thanks
janker67 commented
Did you find an answer to your question? We are trying to find a way to pass a Video Name vs. the Video URL into the event label. using the API might be a workaround.
vpodk commented
@janker67, try the getVideoData
method, it returns the author
, title
and video_id
:
window.onYouTubeIframeAPIReady = function() {
var player = new YT.Player('player', {
...
'events': {
'onStateChange': function(event) {
var data = event.target.getVideoData();
console.log(data.title);
}
}
})
};