0
我正在尝试使用jQuery为我的html5视频创建控制按钮,该视频在本地托管。但我似乎无法得到按钮的工作。我尝试了不同的编码方法,但似乎工作。使用jQuery控制HTML5视频
$(function(){
var video = $('#video').get(0);
$(document).delegate('#play-button', 'click', function() {
video.load();
video.play();
$('#play-button').addClass('hide');
});
$(document).delegate('#pause', 'click', function() {
if (video.play() === true) {
video.pause();
} else {
$('#pause > img').attr('src', 'image/play.png');
video.play();
}
});
$(document).delegate('#stop', 'click', function() {
video.stop();
video.currentTime = 0;
});
});
<div id="video-controls">
<button type="button" role="button" id="play-button"><img src="<?php echo get_template_directory_uri() ?>/images/play.png" alt="play"></button>
<button type="button" role="button" id="pause"><img src="<?php echo get_template_directory_uri() ?>/images/pause.png" alt="pause"></button>
<button type="button" role="button" id="stop"><img src="<?php echo get_template_directory_uri() ?>/images/stop.png" alt="stop"></button>
</div>
我想要做的是显示在视频中间的播放按钮,一旦点击它会播放视频,但然后隐藏。因此,要暂停和停止视频,用户需要将鼠标悬停在视频上,控件才会显示。
任何意见将不胜感激。感谢您花时间看我的问题。
暂停时,你永远不会再出现了'#播放button' –
.stop()方法不会在HTML5视频存在 – Luca
谢谢你让我知道@ RokoC.Buljan –