我试图从具有多个视频的页面获取当前视频源,它们由id分隔。jquery视频html5多个视频添加
例子是如下
<video id="videoOne"
controls src="videoOne.mp4"
</video>
<video id="videoTwo"
controls src="videoTwo.mp4"
</video>
我能够发挥轨道哪些事件改变了0到1烧成引用相应的视频我只需要能够通过jQuery做到这一点,但我不确定如何完成此操作
var current_source = $('video')[0] .currentSrc;
在下面的jQuery
var PodcastAnalytics = PodcastAnalytics || {};
// Wait for the video element to be parsed before attempting this.
$(document).ready(function(){
// Wait until the video metadata has been loaded before we try to determine the current video source.
$('video').on('loadedmetadata', function(){
// Simple function to chop off the file extension for the current source of the video.
PodcastAnalytics.audio_url = (function(){
var current_source = $('video')[0].currentSrc;
return current_source.slice(0, -4);
}());
// function that sends the actual tracking beacon
PodcastAnalytics.gaq_track = function(action) {
// All events will be in the Video category
var tracking_params = ['podcast','audio']
// append the event action after the event method and the event category
tracking_params.push(action);
// append the video url as the event label
tracking_params.push(PodcastAnalytics.audio_url);
// Replace this console.log with something like this if you are using Google Analytics:
// _gaq.push(tracking_params);
console.log(tracking_params);
}
$('video').on('play', function(){
PodcastAnalytics.gaq_track('Play');
});
$('video').on('pause', function(){
PodcastAnalytics.gaq_track('Pause');
});
$('video').on('seeked', function(){
PodcastAnalytics.gaq_track('Seeked');
});
$('video').on('ended', function(){
PodcastAnalytics.gaq_track('Ended');
});
});
});
感谢我没有更新我原来的职位的建议,新的jquery现在正在跟踪正确的 – ondrovic
你应该保持原来的状态,并将你的更正后的代码作为一个单独的答案提交,然后将其作为正确答案接受。这为其他人留下了一条好路。 –