2012-06-30 14 views
0

我的問題是:得到錯誤#2060在本地主機(jPlayer.swf)

  • This fiddle爲我工作。
  • 但是當我複製粘貼相同的代碼(includeing jQuery的正確的路徑,jplayer和Jplayer.swf)我得到一個錯誤:

的ActionScript錯誤#2060

SecurityError: Error #2060: Naruszenie obszaru izolowanego: element wywołujący ExternalInterface http://www.jplayer.org/latest/js/Jplayer.swf nie może uzyskać dostępu do null. 
    at flash.external::ExternalInterface$/_evalJS() 
    at flash.external::ExternalInterface$/call() 
    at Jplayer/init() 
    at flash.utils::Timer/_timerDispatch() 
    at flash.utils::Timer/tick() 

爲什麼相同的代碼在遠程服務器上工作(如jsfiddle),但本地文件會引發錯誤?

如何在本地機器上運行此代碼?

這是怎麼test.html的樣子:

<!DOCTYPE html> 
<html> 
<head> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
    <title>Play a Shoutcast stream - jsFiddle demo</title> 

    <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script> 
    <script type='text/javascript' src="http://www.jplayer.org/latest/js/jquery.jplayer.min.js"></script> 

    <script type='text/javascript'>//<![CDATA[ 
    $(function(){ 
    $("#jquery_jplayer_1").jPlayer({ 
     swfPath: "Jplayer.swf", 
     ready: function() { 
      $(this).jPlayer("setMedia", { mp3: "http://94.23.108.1:8018/;stream/1" }); 
     }, 
     supplied: "mp3" 
    }); 
    });//]]> 

    </script> 
</head> 
<body> 
    <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-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 class="jp-title"> 
     <ul> 
      <li>Testing</li> 
     </ul> 
     </div> 
     <div class="jp-no-solution"> 
     <span>Update Required</span> To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>. 
     </div> 
    </div> 
    </div> 
</body> 
</html> 
+0

你使用jQuery是撥弄使用相同版本的? –

回答

0

閱讀this post後,我找到了解決辦法是:

Previewing in

http://localhost
instead of
file://
You can view these files on localhost instead of the file system by changing the following,