1
votes

We are embedding a youtube player into our page. Easy implementation of code and html5 support driven us to use the youtube iframe player.

Problem is that view count does not work with the api. No video does not autoplay and we are playing the video with youtube's default play button.

When I revert back to a AS3 player view count seems to work.

Is it a bug in the iframe api? Anyone come across a solve?

Thanks!!!

2

2 Answers

0
votes

Views that originate as a result of clicking on one of the native player UI elements (either the play button in the control bar or on the static player image) will normally count towards incrementing the views for a video. There are obviously other signals that could come into play, but all things being equal, there's no reason why using an <iframe> embed vs. an ActionScript 3 embed should prevent views from being counted.

If you have a specific example of your implementation that you want to pass along, I can take a look and see if you're doing anything unorthodox.

0
votes

we have created a simple test html file with a video using the YouTube iFrame API, as the idea is to have the videoplayer fall back to the HTML5 videoplayer on mobile devices. However views are not being counted on click to play video: http://www.youtube.com/watch?v=-LHUt9FGgys

In the body of the html we have the following:

<div id="player"></div>

<script>
var tag = document.createElement('script');

tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: '-LHUt9FGgys',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}


function onPlayerReady(event) {
  //event.target.playVideo();
}

var done = false;
function onPlayerStateChange(event) {
// if (event.data == YT.PlayerState.PLAYING && !done) {
// setTimeout(stopVideo, 6000);
// done = true;
// }
}
function stopVideo() {
player.stopVideo();
}
</script>

It would be interesting to see if you or someone else has a solution for this. Thanks!