flash - ActionScript 3 - Live streaming: how do you listen for multiple FMS URLs? -
sometimes have live streaming services breakdown.
everyone helpless , live stream ends.
if can listen multiple sources in 1 player, can play new source.
i'm not planning on playing 2 @ once, having 1 or more backups can start using if 1 breaks down.
i'm using random fms url rtmp live stream link example:
rtmp://81.177.35.218/rtp/2
there more fms urls here work.
also, if code looks bad, particularly under public function onmetadata(data)
, feel free fix , edit it.
this template, , 1 of few parts edited myself.
i appreciate if reply contained same code edited. don't know i'm doing.
package { import flash.accessibility.accessibility; import flash.display.sprite; import flash.events.*; import flash.net.netconnection; import flash.net.netstream; import flash.media.video; public class nslive10_7castwesttigerss extends sprite { private var nc:netconnection; private var ns:netstream; private var video:video; public function nslive10_7castwesttigerss() { video = new video(); addchild(video); nc = new netconnection(); nc.objectencoding = 0; nc.client=this; nc.addeventlistener(netstatusevent.net_status, onnetstatus); nc.addeventlistener(asyncerrorevent.async_error, onerror); nc.connect('rtmp://81.177.35.218/rtp'); } private function startstreaming() { ns = new netstream(nc); ns.client = this; ns.addeventlistener(netstatusevent.net_status, onnetstatus); ns.addeventlistener(asyncerrorevent.async_error, onerror); ns.play("2"); video.attachnetstream(ns); } private function onnetstatus(event:netstatusevent):void { switch(event.info.code) { case 'netconnection.connect.success': trace('netconnection.connect.success'); startstreaming(); break; default: trace(event.info.code); } } private function onerror(event:asyncerrorevent):void { trace(event); } public function onmetadata(data) { for(var in data){ trace(i + " = " + data[i])} video.width = data.width; video.height = data.height; video.width = stage.stagewidth; video.height = stage.stageheight; video.x = (stage.stagewidth - video.width)/2; video.y = (stage.stageheight - video.height)/2; } public function onbwdone () { trace("on bandwidth done "); } } }
tl;dr
in as3 live streaming, how make able play live streams different sources , urls?
make playlist (simple array rtmp url's) , listen statuses of netstream , netconnection. in case bad status switch next url , on.
complete list of available statuses can find here: for netstream , netconnection
Comments
Post a Comment