如何跟踪嵌入视频(youtube、vimeo 等)的点击事件?(跟踪播放次数) [英] How can I track a click event of an embedded video (youtube, vimeo, etc.)? (to track play count)
本文介绍了如何跟踪嵌入视频(youtube、vimeo 等)的点击事件?(跟踪播放次数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法跟踪嵌入视频的播放次数?理想情况下,不要使用链接的缩略图来启动嵌入/iframe 代码.
示例(在 jsFiddle 上自己尝试):
<html lang="zh-cn"><头><meta charset="utf-8"><title>示例</title><script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>头部><身体><div id="日志"></div><ul><li class="video" id="video1"><iframe width="480" height="390" src="http://www.youtube.com/embed/z6lL83wl31E" frameborder="0"allowfullscreen></iframe><li><li class="video" id="video2"><iframe src="http://player.vimeo.com/video/28231570?title=0&byline=0&portrait=0" width="400" height="225" frameborder="0"></iframe></li><li class="video" id="video3"><embed flashVars="playerVars=autoPlay=no" src="http://www.metacafe.com/fplayer/3153323/the_three_stooges_minisode_beer_barrel_polecats_season_1_episode_0008"width="440" height="248" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_3153323" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></li><脚本>/* 这是我迄今为止尝试过的: */$('.video').mouseover(function(){$('#log').html('鼠标悬停!');/*alert('改为跟踪鼠标悬停?这是我能做的最好的吗?');*/});$('.video').mouseout(function(){$('#log').html(' ');});$('.video').mousedown(function(){$('#log').html('鼠标按下!');警报('鼠标按下');/* 这将跟踪嵌入对象(不是 iframes)中的 mousedown 事件,但不允许单击事件传递给对象.*/});