6
我想用jquery播放/暂停视频。使用jquery播放/暂停HTML5视频
这里是我的代码:
(function ($) {
// plugin definition
$.fn.htmlvideo = function (options) {
// build main options before element iteration
var defaults = {
theme: 'normal',
};
var options = $.extend(defaults, options);
// iterate and reformat each matched element
return this.each(function() {
var $htmlvideo = $(this);
addvideo();
addcontrols();
function addvideo() {
var addvideo = $('<video width="1000"><source src="http://devfiles.myopera.com/articles/2642/sintel-trailer.ogv" type="video/ogg; codecs="theora, vorbis""><source src="http://devfiles.myopera.com/articles/2642/sintel-trailer.mp4" type="video/mp4; codecs="avc1.42E01E, mp4a.40.2""></video>');
$(addvideo).appendTo('#video');
}
function addcontrols() {
var controls = $('<div id="controls" class="controls"><button id="playbtn" class="playbtn"></button></div>');
$(controls).appendTo('#controlspane');
}
$('.playbtn').click(function() {
//Here I need to make the video play
});
});
};
})(jQuery);
@ 3nigma,再次感谢我的排序问题。 – coder 2012-03-25 21:38:53
很高兴帮助,从上一个问题我注意到,你使用的锚点和视频控制中的多个ID,这是错误的ids应该是唯一的... – Rafay 2012-03-25 21:40:00
当然,我不会再那样做。感谢指出。 – coder 2012-03-25 21:41:05