Travaillant sur la création d'un lecteur vidéo, et pour une raison quelconque, le flux RTMP est introuvable. Je dois manquer quelque chose d'évident, mais je n'arrive pas à trouver où. Le flux que je suis en train de tester est rtmp: //cp67126.edgefcs.net/ondemand/mediapm/osmf/content/test/akamai_10_year_f8_512K qui est définitivement là.Flux RTMP non trouvé dans AS3
package { import com.bfwpub.data.*;
import flash.display.Sprite;
import flash.events.AsyncErrorEvent;
import flash.events.ErrorEvent;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.NetStatusEvent;
import flash.events.SecurityErrorEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextField;
public class BFW_VideoPlayer extends Sprite
{
private static const PLAYER_CONFIG:String = "data/player_config.xml";
private var _video:Video;
private var _playerData:PlayerData;
private var _videoData:VideoData;
private var _controlbarData:ControlBarData;
private var _videoPath:String;
private var _debugTxt:TextField;
// net connection object for net stream
private var _ncConnection:NetConnection;
// net stream object
private var _nsStream:NetStream;
public function BFW_VideoPlayer()
{
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, loadConfig);
xmlLoader.load(new URLRequest(PLAYER_CONFIG));
}
private function loadConfig(e:Event):void
{
var config:XML = new XML(e.target.data);
//store data in Objects
_playerData = new PlayerData();
_videoData = new VideoData();
_controlbarData = new ControlBarData();
//populate PlayerData
_playerData.autoPlay = [email protected];
_playerData.autoRewind = [email protected];
_playerData.smoothing = [email protected];
_playerData.height = [email protected];
_playerData.isLive = [email protected];
_playerData.scaleMode = [email protected];
_playerData.width = [email protected];
//populate VideoData
_videoData.deliveryType = config.mediaElement.deliveryType;
_videoData.file = config.mediaElement.file;
_videoData.mediaPath = config.mediaElement.mediaPath;
_videoData.streamType = config.mediaElement.streamType;
_videoData.buffer = config.mediaElement.buffer;
//populate ControlBarData
_controlbarData.autoHide = config.controlBar.autoHide;
_controlbarData.captionPath = config.controlBar.captionPath;
_controlbarData.fullScreen = config.controlBar.fullScreen;
_controlbarData.skinPath = config.controlBar.skinPath;
//_videoPath = "rtmp://"+_videoData.mediaPath+_videoData.file;
_videoPath = "rtmp://cp67126.edgefcs.net/ondemand/mediapm/osmf/content/test/akamai_10_year_f8_512K"
createPlayer();
}
private function createPlayer():void
{
_debugTxt = new TextField();
_debugTxt.width = 200;
_debugTxt.height = 200;
this.addChild(_debugTxt);
_video = new Video();
_video.height = _playerData.height;
_video.width = _playerData.width;
this.addChild(_video);
createConnection();
}
private function createConnection():void
{
// create a new net connection, add event listener and connect
// to null because we don’t have a media server
_ncConnection = new NetConnection();
_ncConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
_ncConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
_ncConnection.addEventListener(IOErrorEvent.IO_ERROR,errorHandler);
_ncConnection.addEventListener(AsyncErrorEvent.ASYNC_ERROR,metaHandler);
_ncConnection.connect(null);
}
/** Catch security errors. **/
private function errorHandler(evt:ErrorEvent):void {
trace("[ErrorEvent]"+evt.text)
};
/** Catch noncritical errors. **/
private function metaHandler(evt:ErrorEvent):void {
trace("[ErrorEvent]"+evt.text)
};
private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
public function netStatusHandler(event:NetStatusEvent):void
{
trace("["+event.info.code+"]");
_debugTxt.text += "["+event.info.code+"]\n";
switch (event.info.code) {
case "NetConnection.Connect.Success":
connectStream();
break;
case "NetStream.Play.StreamNotFound":
trace("Stream not found: " + _videoPath);
break;
}
}
private function connectStream():void {
_nsStream = new NetStream(_ncConnection);
_nsStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
_nsStream.bufferTime = _videoData.buffer;
_nsStream.client = new Client();
_video.attachNetStream(_nsStream);
_video.smoothing = _playerData.smoothing;
_nsStream.play(_videoPath);
}
}
}
Intéressant, semble que si je vois un FVL via http: // cela fonctionne. Doit être un problème de pare-feu peut-être? – abritez