我正在尝试在视频到达结束时显示图片,但它不起作用,现在我有了这段代码:
// Change image to video on click(working)
$('#image').click(function() {
video = '<video id="video" muted autoplay poster="/img.png" controls style="width: 100%; height: auto; z-index: 999999;"><source src="/video.m4v"></video>';
jQuery(this).replaceWith(video);
});
// Detect end of video(not working)
$('video').on('ended', function() {
alert("End of te video!");
});
警报没有弹出,请记住,此代码在桌面上运行正常,但在移动设备上无法正常运行,任何建议都会受到赞赏,
谢谢!
答案 0 :(得分:0)
您需要为已结束的事件
创建一个新的EventListener示例:
video.addEventListener('ended', function(){
//Your Code goes here
})
success: function (video, domObject) {
// add event listener
YourMediaElement.addEventListener('ended', function(e) {
//Do Stuff here
}, false);
我复制了以下链接checck中的代码,以获取更多信息...
How to call a function on video end ? (HTML5 and mediaelementjs)