Jplayer音频不能在Firefox,Opera和IE中运行,但可以在Chrome中使用

时间:2013-01-28 03:49:45

标签: javascript jquery audio jplayer

http://www.jplayer.org/support/ - 这是jplayer suppost(向下滚动以查看jplayer在IE 6,7,8,firefox和opera中不起作用的地方

设置jplayer音频javascript:http://www.jplayer.org/latest/quick-start-guide/step-7-audio/

现在的问题是,即使jplayer音频播放器在Chrome上运行,它也无法在IE,firfox和Opera上运行。我的问题是,FAQ中提到的问题是.swfPath的src是不正确的?

swf文件的完整目录是helios.hud.ac.uk/u0867587/Mobile_app/jquery/Jplayer.swf

应用previewaudio.phphelios.hud.ac.uk/u0867587/Mobile_app/previewaudio.php

jquery是:

<script type="text/javascript">   
    $(document).ready(function(){
  $("#jquery_jplayer_1").jPlayer({
    ready: function () {
      $(this).jPlayer("setMedia", {
        m4a: "<?php echo $dbAudioFile; ?>",
        oga: "<?php echo $dbAudioFile; ?>"
      });
    },
    swfPath: "jquery/",
    supplied: "m4a, oga"
  });
}); 
</script>

我在firebug中得到这个:不支持“audio / mpeg”的HTTP“Content-Type”。“这是什么意思?

以下是音频的链接:AUDIO

更新

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>Preview Audio</title>
    <link type="text/css" href="jquery/skin/jplayer.blue.monday.css" rel="stylesheet" />
    <script type="text/javascript" src="jquery/jquery-1.7.min.js"></script>   
    <script type="text/javascript" src="jquery/jquery.jplayer.min.js"></script>
</head>

<body>


<?php

$getaudio = 'AudioFiles/' . $_GET['filename'];

$audioquery = "SELECT AudioFile FROM Audio WHERE (AudioFile = ?)";

        if (!$audiostmt = $mysqli->prepare($audioquery)) {
        // Handle errors with prepare operation here
}


// Bind parameter for statement
$audiostmt->bind_param("s", $getaudio);

// Execute the statement
$audiostmt->execute();

            if ($audiostmt->errno) 
            {
                // Handle query error here
            }

$audiostmt->bind_result($dbAudioFile); 

$audiostmt->fetch(); 

$audiostmt->close(); 

?>

<script type="text/javascript">   
    $(document).ready(function(){
  $("#jquery_jplayer_1").jPlayer({
    ready: function () {
      $(this).jPlayer("setMedia", {
        m4a: "<?php echo "http://helios.hud.ac.uk/u0867587/Mobile_app/".$dbAudioFile; ?>",
        mp3: "<?php echo "http://helios.hud.ac.uk/u0867587/Mobile_app/".$dbAudioFile; ?>",
        oga: "<?php echo "http://helios.hud.ac.uk/u0867587/Mobile_app/".$dbAudioFile; ?>"
      });
    },
    solution:"flash,html",
    swfPath: "jquery",
    supplied: "m4a, mp3, oga"
  });
}); 
</script>
<?php echo "File Path " . $dbAudioFile; ?>
  <div id="jquery_jplayer_1" class="jp-jplayer"></div>
  <div id="jp_container_1" class="jp-audio">
    <div class="jp-type-single">
      <div class="jp-gui jp-interface">
        <ul class="jp-controls">
          <li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
          <li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
          <li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
          <li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li>
          <li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>
          <li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li>
        </ul>
        <div class="jp-progress">
          <div class="jp-seek-bar">
            <div class="jp-play-bar"></div>
          </div>
        </div>
        <div class="jp-volume-bar">
          <div class="jp-volume-bar-value"></div>
        </div>
        <div class="jp-time-holder">
          <div class="jp-current-time"></div>
          <div class="jp-duration"></div>
          <ul class="jp-toggles">
            <li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a></li>
            <li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a></li>
          </ul>
        </div>
      </div>
    </div>
  </div>

</body>

1 个答案:

答案 0 :(得分:4)

我在这里发现了一些问题Audio 这是你的代码:

<script type="text/javascript">   
    $(document).ready(function(){
  $("#jquery_jplayer_1").jPlayer({
    ready: function () {
      $(this).jPlayer("setMedia", {
        mp3: "AudioFiles/Thorne, Grandma's Goodbye excerpt_4.m4a",
        oga: "AudioFiles/Thorne, Grandma's Goodbye excerpt_4.m4a"
      });
    },
    swfPath: "/jquery",
    supplied: "mp3, oga"
  });
}); 
</script>

您需要将swfPath更改为正确的solution。您还需要设置<script type="text/javascript"> $(document).ready(function(){ $("#jquery_jplayer_1").jPlayer({ ready: function () { $(this).jPlayer("setMedia", { m4a: "http://helios.hud.ac.uk/u0867587/Mobile_app/AudioFiles/AudioFiles/Thorne, Grandma's Goodbye excerpt_4.m4a", oga: "http://helios.hud.ac.uk/u0867587/Mobile_app/AudioFiles/AudioFiles/Thorne, Grandma's Goodbye excerpt_4.m4a" }); }, solution:"flash,html", swfPath: "jquery", supplied: "m4a, oga" }); }); </script>

请尝试以下代码:

<script type="text/javascript">   
    $(document).ready(function(){
  $("#jquery_jplayer_1").jPlayer({
    ready: function () {
      $(this).jPlayer("setMedia", {
        mp3: "http://path/to/file.mp3"
      });
    },
    solution:"flash,html",
    swfPath: "jquery",
    supplied: "mp3"
  });
}); 
</script>

这应该有所帮助。

<强>更新 现在,您将为所有格式(mp3,m4a,oga)提供相同的文件。这是错误的,您需要为每种格式定义合适的供应商和来源。

<强> MP3:

<script type="text/javascript">   
    $(document).ready(function(){
  $("#jquery_jplayer_1").jPlayer({
    ready: function () {
      $(this).jPlayer("setMedia", {
        m4a: "http://path/to/file.m4a"
      });
    },
    solution:"flash,html",
    swfPath: "jquery",
    supplied: "m4a"
  });
}); 
</script>

<强> M4A:

<script type="text/javascript">   
    $(document).ready(function(){
  $("#jquery_jplayer_1").jPlayer({
    ready: function () {
      $(this).jPlayer("setMedia", {
        oga: "http://path/to/file.oga"
      });
    },
    solution:"flash,html",
    swfPath: "jquery",
    supplied: "oga"
  });
}); 
</script>

<强> OGA:

<script type="text/javascript">   
    $(document).ready(function(){
  $("#jquery_jplayer_1").jPlayer({
    ready: function () {
      $(this).jPlayer("setMedia", {
        mp3: "http://path/to/file.mp3"
        m4a: "http://path/to/file.m4a"
        oga: "http://path/to/file.oga"
      });
    },
    solution:"flash,html",
    swfPath: "jquery",
    supplied: "mp3, m4a, oga"
  });
}); 
</script>

mp3,m4a,oga

<script type="text/javascript">   
    $(document).ready(function(){
  $("#jquery_jplayer_1").jPlayer({
    ready: function () {
      $(this).jPlayer("setMedia", {
        m4a: "<?php echo "http://helios.hud.ac.uk/u0867587/Mobile_app/".$dbAudioFile; ?>",
        mp3: "<?php echo "http://helios.hud.ac.uk/u0867587/Mobile_app/".$dbAudioFile; ?>",
        oga: "<?php echo "http://helios.hud.ac.uk/u0867587/Mobile_app/".$dbAudioFile; ?>"
      });
    },
    solution:"flash,html",
    swfPath: "jquery",
    supplied: "m4a, mp3, oga"
  });
});

<强> UPDATE2

回到你的php代码,改变这个:

<?php
    $file_info = pathinfo($dbAudioFile);
    $ext = $file_info['extension'];
?>

<script type="text/javascript">   
    $(document).ready(function(){
  $("#jquery_jplayer_1").jPlayer({
    ready: function () {
      $(this).jPlayer("setMedia", {
        <?php echo $ext;?>: "<?php echo "http://helios.hud.ac.uk/u0867587/Mobile_app/".$dbAudioFile; ?>"
      });
    },
    solution:"flash,html",
    swfPath: "jquery",
    supplied: "<?php echo $ext;?>"
  });
}); 

将其更改为:

{{1}}