无法使用jQuery在firefox中暂停视频

时间:2012-07-09 17:09:42

标签: jquery html5-video mediaelement.js

HTML:

<video class="0" autoplay="true" width="586px" height="440" src=""></video>

JS:

$('video').mediaelementplayer();

if($('video').attr('class') == "0"){
    $('video')[0].player.pause();
}

在Chrome中,视频暂停正常。但是在Firefox中没有暂停。任何想法如何解决这个问题?

3 个答案:

答案 0 :(得分:1)

试试这个:

if($('video').attr('class') == "0"){
    $('video')[0].pause();
}

答案 1 :(得分:1)

试试这样:

 $("video").get(0).pause();

...

<video class='0' id='video_01'
  controls preload='none'  src="http://media.w3.org/2010/05/sintel/trailer.webm"
  poster="http://media.w3.org/2010/05/sintel/poster.png"   

  <p>Your user agent does not support the HTML5 Video element.</p>
</video>

function callPause(){  
    if($('video').attr('class') == "0"){
     $("video").get(0).pause();
     }
   return false;
   }

示例小提琴:Here

答案 2 :(得分:1)

这会暂停您的视频

$('video[class="0"]').get(0).pause()

演示:http://jsbin.com/eyepat/2/edit#javascript,html

在旁注类中,不能以整数http://www.w3schools.com/tags/att_standard_class.asp

开头
相关问题