這個問題發生的是IE8和IE7。我有一個用flex編譯的小swf。它基本上只是音頻流功能的一個包裝。所有的控件和這些都在與JavaScript的HTML。我使用swfobject的「靜態」方法加載swf。這在Firefox和Chrome中非常有用。在IE中,swf加載正確,但只要我嘗試使用它流式傳輸任何音頻,就會出現錯誤。IE不讓閃存流音頻
編輯:我已經減少了相當多的代碼,試圖找到問題。您可以看到運行here的新版本。以下是錯誤,HTML和Flex文件我的簡化版本:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at isolated/playStream()[/home/defrex/code/bd/trunk/ackbar/media/flex/isolated.mxml:19]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at flash.external::ExternalInterface$/_callIn()
at <anonymous>()
的HTML:
<!DOCTYPE html>
<html>
<head>
<title>fuie</title>
<script type="text/javascript" src="swfobject.js"></script>
<script>
var player;
swfobject.registerObject("_mediaplayer", "9.0.0", undefined, function(e){
if (e.success)
player = e.ref;
else
console.log('Flash not loaded');
});
</script>
</head>
<body>
<a href="#" onclick="player.play_fuie('celebration.mp3');return false;">play track</a>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1" height="1" id="_mediaplayer">
<param name="movie" value="isolated.swf" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="isolated.swf" width="1" height="1">
</object>
<!--<![endif]-->
</object>
</body>
</html>
和Flex:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
import flash.external.ExternalInterface;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
public function init():void {
ExternalInterface.addCallback("play_fuie", playStream);
ExternalInterface.call("console.log('flash loaded')");
}
public function playStream(stream:String):void {
var url:URLRequest = new URLRequest(stream);
var audio:Sound = new Sound();
audio.load(url);
var chan:SoundChannel = audio.play();
chan.soundTransform.volume = 0.5;
}
</mx:Script>
</mx:Application>
我編輯了這個問題來顯示這個,但是這個函數是通過ExternalInterface調用的。它以JavaScript的字符串形式傳入。 – defrex 2009-12-11 15:34:42
我只是遇到了這個(有些痛苦,因爲我也使用應該在mac上運行的外部接口)。 http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html 使用ExternalInterface類的瀏覽器和操作系統的組合: 瀏覽器操作系統操作系統 Internet Explorer 5.0中後來的Windows 的Netscape 8.0及更高版本Windows MacOS的 的Mozilla 1.7.5及更高版本Windows MacOS的 Firefox 1.0及更高版本Windows MacOS的 的Safari 1.3及更高版本的MacOS 所以如果你在Mac上運行的可能是一個問題。 – Eran 2009-12-11 16:14:54
mabe這將有助於: http://stackoverflow.com/questions/1166079/externalinterface-not-working-in-ie – Eran 2009-12-11 16:26:44