Firefox错误 - 使用jQuery克隆视频时,视频不会静音?

时间:2017-02-28 15:54:51

标签: javascript jquery firefox html5-video

当使用jQuery克隆视频元素时,Firefox不会将视频静音。

JS:

$( document ).ready(function() {

    var origin = $('.item-video');
    var target = $('.clone');

    origin.clone(true).appendTo(target);
    origin.empty();fix

});

HTML:

 <div class="item-video">
    <video width="560" height="315" autoplay muted controls loop>
        <source src="big-buck-bunny_trailer.webm" type="video/webm">
        <!-- <source src="http://video.webmfiles.org/big-buck-bunny_trailer.webm" type="video/webm"> -->
    </video>
    <a href="yourpage.html" class="button-video"></a>
</div>

<div class="clone">

</div><div class="item-video">
    <video width="560" height="315" autoplay muted controls loop>
        <source src="big-buck-bunny_trailer.webm" type="video/webm">
        <!-- <source src="http://video.webmfiles.org/big-buck-bunny_trailer.webm" type="video/webm"> -->
    </video>
    <a href="yourpage.html" class="button-video"></a>
</div>

<div class="clone">

</div>

jsfiddle

我有什么想法修复 Firefox上的错误

1 个答案:

答案 0 :(得分:1)

我不知道为什么会在FF上发生这种情况,但这是解决方法

origin.clone(true).appendTo(target).find('video').attr('onloadedmetadata','this.muted =true');