1

我在所有页面(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>

有什么问题? 我的网站链接

4

2 回答 2

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 之外的所有浏览器中都有效,有什么想法吗?

于 2012-04-25T10:46:44.797 回答
1

更改$selectors$(selectors)

于 2012-04-17T22:15:40.043 回答