jPlayer暂停

时间:2012-04-17 05:28:31

标签: jquery jplayer

我在所有页面上都播放了背景音乐(jPlayer),我需要在帖子或页面或侧边栏上点击/播放另一个嵌入视频时暂停它,尽管此代码似乎不起作用:

<script>
//pauses jplayer
var selectors = [
        "iframe[src^='http://player.vimeo.com']", 
        "iframe[src^='http://www.youtube.com']", 
        "iframe[src^='https://www.youtube.com']", 
        "iframe[src^='http://www.kickstarter.com']", 
        "object", 
        "embed"
      ];
  $selectors.click(function() {
  $.jPlayer.pause();
});
</script>
什么可能是错的? mysite link

2 个答案:

答案 0 :(得分:1)

$selectors更改为$(selectors)

答案 1 :(得分:1)

// By Chris Coyier & tweaked by Mathias Bynens
$(function() {
// Find all videos
var selectors = [
    "iframe[src^='http://player.vimeo.com']", 
    "iframe[src^='http://www.youtube.com']", 
    "iframe[src^='https://www.youtube.com']", 
    "iframe[src^='http://www.kickstarter.com']", 
    "object", 
    "embed"
  ];
    // The element that is fluid width
var $allVideos = $(this).find(selectors.join(','));
// Figure out and save aspect ratio for each video
$allVideos.each(function() {
var $this = $(this);
$(this).hover(function(){
        $("#bgaudio").jPlayer("pause");
    },function(){
        $("#bgaudio").jPlayer("play");
    });
});
});

“点击”对于不同的视频提供商来说很复杂 - “悬停”适用于所有浏览器,除了Chrome,任何想法?