Are YouTube view counts incremented when using the iframe Player?

巧了我就是萌 提交于 2019-12-24 08:24:11

问题


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!!!


回答1:


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.




回答2:


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!



来源:https://stackoverflow.com/questions/15418239/are-youtube-view-counts-incremented-when-using-the-iframe-player

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!