使用 iframe 播放器时,YouTube 观看次数是否会增加? [英] Are YouTube view counts incremented when using the iframe Player?

查看:19
本文介绍了使用 iframe 播放器时,YouTube 观看次数是否会增加?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将 YouTube 播放器嵌入到我们的页面中.代码的轻松实现和 html5 支持促使我们使用 youtube iframe 播放器.

问题是视图计数不适用于 api.没有视频不会自动播放,我们正在使用 youtube 的默认播放按钮播放视频.

当我恢复到 AS3 播放器观看次数似乎有效.

这是 iframe api 中的错误吗?有人遇到过解决方法吗?

谢谢!!!

解决方案

我们使用 YouTube iFrame API 创建了一个带有视频的简单测试 html 文件,因为我们的想法是让视频播放器回退到移动设备上的 HTML5 视频播放器设备.但是,点击播放视频不计算观看次数:http://www.youtube.com/watch?v=-LHUt9FGgys>

在 html 的正文中,我们有以下内容:

<div id="player"></div><脚本>var tag = document.createElement('script');tag.src = "//www.youtube.com/iframe_api";var firstScriptTag = document.getElementsByTagName('script')[0];firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);var 播放器;函数 onYouTubeIframeAPIReady() {player = new YT.Player('玩家', {高度:'390',宽度:'640',videoId: '-LHUt9FGgys',事件:{'onReady': onPlayerReady,'onStateChange': onPlayerStateChange}});}函数 onPlayerReady(event) {//event.target.playVideo();}变量完成 = 假;函数 onPlayerStateChange(event) {//if (event.data == YT.PlayerState.PLAYING && !done) {//setTimeout(stopVideo, 6000);//完成 = 真;//}}功能停止视频(){player.stopVideo();}

看看您或其他人是否有解决方案会很有趣.谢谢!

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

解决方案

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!

这篇关于使用 iframe 播放器时,YouTube 观看次数是否会增加?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆