![]() |
|
||||||||||
|
|||||
|
[+ 1.0 08.10.14]
блогер
Регистрация: Mar 2010
Адрес: x = stage.stageWidth/2 y= stage.stageHeight/2
Сообщений: 293
Записей в блоге: 2
|
Ребят помогите разобраться один и тот же код, в одном приложении работает в другом нет. Просто жесть какая - то.
private var netConnection:NetConnection; private var ns:NetStream; private var video:Video; private var client:CustomClient; private var url:String = 'rtmp://173.220.21.178:1935/vod'; //private var url:String = 'rtmp://192.168.0.35:1935/vod'; public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); // entry point netConnection = new NetConnection (); netConnection.addEventListener(NetStatusEvent.NET_STATUS, OnNetStatus); netConnection.addEventListener(IOErrorEvent.IO_ERROR, OnIOError); netConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, OnSecurityError); netConnection.connect(url, {}); } private function OnIOError(e:IOErrorEvent):void { log("IO error: " + e.text); } private function OnSecurityError(e:SecurityErrorEvent):void { log("Security error: " + e.text); } protected function OnNetStatus(e:NetStatusEvent):void { switch(e.info.code) { case "NetConnection.Connect.Success": log('Connection to ' + netConnection.uri + ' success'); connectSuccess (); break; case "NetConnection.Connect.Rejected": log('Connection to ' + netConnection.uri + ' rejected'); break; case "NetConnection.Connect.Failed": log('Failed connect to ' + netConnection.uri); break; case "NetConnection.Connect.Closed": log('Connection to ' + netConnection.uri + ' closed'); break; case "NetStream.Play.Start": { log ('play Start'); break; } default: log(e.info.code); } } protected function connectSuccess () :void { trace ('onConnectSuccess'); client = new CustomClient (); //client.addEventListener ('clientOnMetaData', onClientMetaData); //client.addEventListener (StreamClientEvent.ON_CUE_POINT, logStatus); //client.addEventListener (StreamClientEvent.ON_PLAY_STATUS, logStatus); ns = new NetStream(netConnection); ns.addEventListener(NetStatusEvent.NET_STATUS, OnNetStatus); // netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); ns.client = client; video = new Video (590, 300) video.attachNetStream(ns); // this.addChild (video); this.stage.addEventListener (MouseEvent.CLICK, onClick); } private function onClick (event:MouseEvent) :void { //netStream.close (); ns.play ('1LD.mp4'); } private function asyncErrorHandler(event:AsyncErrorEvent):void { log (event.text); } private function onClientMetaData (event:Event) :void { trace ('fkjdj') //log (event.message); } private function logStatus (event:StreamClientEvent) :void { log (event.message); } protected function log (string:String) :void { trace (string); //if (ExternalInterface.available) JSInterface.window.alert (string); } } } 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); } } В двух словах, никаких ошибок не выдает, но событие onMetaData не срабатывает и видео тупо на сцену не добавляется Последний раз редактировалось inozemcev; 19.05.2011 в 19:17. |
![]() |
![]() |
Часовой пояс GMT +4, время: 07:30. |
|
|
« Предыдущая тема | Следующая тема » |
|
|