我在這個網站上發現了Flash AS3中的shoutcast streaming的代碼。 這是代碼:shoutcast streaming Flash AS3?
錯誤打開URL的 'https:// MYHOST:MyPort上' 的SecurityError:錯誤#2000:
package {
import flash.display.Sprite;
import flash.events.NetStatusEvent;
import flash.events.SecurityErrorEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.Event;
public class NetConnectionExample extends Sprite {
private var streamURL:String = "https://myHost:myPort";
private var connection:NetConnection;
private var stream:NetStream;
public function NetConnectionExample() {
connection = new NetConnection();
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
connection.connect(null);
}
private function netStatusHandler(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetConnection.Connect.Success":
connectStream();
break;
case "NetStream.Play.StreamNotFound":
trace("Stream not found: " + streamURL);
break;
}
}
private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
private function connectStream():void {
stream = new NetStream(connection);
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stream.client = new CustomClient();
stream.play(streamURL);
}
}
}
class CustomClient {
public function onMetaData(info:Object):void {
trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
}
public function onCuePoint(info:Object):void {
trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type);
}
}
但是當我編譯SWF我得到這個錯誤沒有活動的安全性上下文。
任何人都可以請告訴我如何正確地做到這一點?我一直在尋找兩天,無濟於事!
感謝
此方法受嚴重內存泄漏。嘗試使用低內存設備,並在幾分鐘內崩潰。或者,讓它在高比特率的數據流上運行幾個小時,然後觀看它在電腦上吃掉所有的RAM。 – Brad 2011-06-10 13:19:24