IE8和IE7都会出现这个问题。我有一个用flex编译的小swf。它基本上只是音频流功能的包装。所有的控件等都是用 html 和 javascript 编写的。我使用 swfobject 的“静态”方法加载 swf。这在 Firefox 和 Chrome 中效果很好。在 IE 中,swf 可以正确加载,但是当我尝试使用它流式传输任何音频时,就会收到错误消息。
编辑:我已经减少了相当多的代码来尝试找到问题。可以看到新版本正在运行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>
还有弹性:
<?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>
最佳答案
经过 3 天令人沮丧的调试后,这个故事的寓意是:软件盗版是很糟糕的。事实证明,开发团队在 VirtualBox 中进行 IE 测试的粗略“XP 海盗版”存在某种错误(或者可能是恶意软件)导致了该问题。当我们尝试在同一虚拟机中安装的 Chrome 中进行测试时,它出现了相同的错误(而 Linux 下的 Chromium 运行良好),我们意识到操作系统可能存在问题。果然,当我们拿到合法版本的 IE 时,一切都运行得很好。
业力可能是残酷的。
关于javascript - IE 不允许 Flash 流音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1883832/