在Chrome中播放视频时,声音每隔一段时间播放一次 [英] Sound plays every other time the Video plays in Chrome

查看:172
本文介绍了在Chrome中播放视频时,声音每隔一段时间播放一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在chrome(7.0.517.44)中,我使用< video> 标记,并且音频每隔一次只播放 视频玩过的。

In chrome (7.0.517.44) I am using the <video> tag and the audio will only play every other time the video is played.

为什么音频不会随视频一起播放?

page:

<div id="VideoShow">
    <video id="VideoPlay" width=800 height=600></video>
</div>

点击此JS运行。

function playVideo(videoName) {
    $("#VideoShow").fadeIn(300);
    var Vid = document.getElementsByTagName('video')[0];
    Vid.src = videoName;
    Vid.play();
    Vid.addEventListener('ended', function(e) {
        closeVideo();
    }, false);
}

function closeVideo() {
    var Vid = document.getElementsByTagName('video')[0];
    Vid.removeEventListener('ended', arguments.callee, false);
    Vid.pause();
    $("#VideoShow").fadeOut(300);
}


推荐答案

我有一个非常类似的问题最近与< audio> 标签。尽管我无法确定实际原因,但我可以通过从DOM中删除旧的< audio> 元素并将其替换为()之前立即使用相同的元素。

I had a very similar problem with the <audio> tag recently. Although I wasn't able to determine the actual cause, I was able to work around the issue by removing the old <audio> element from the DOM and replacing it with an identical element immediately before each call to play().

这篇关于在Chrome中播放视频时,声音每隔一段时间播放一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆