INFO server comment - SecureURLParams.onAppStart: hodtv_live/_definst_ INFO application app-start _definst_ hodtv_live/_definst_ INFO session connect-pending xxx.xxx.xxx.xxx - INFO session connect xxx.xxx.xxx.xxx - INFO stream create - - INFO server comment - SecureURLParams: play: rejected
livestream.streamer=rtmp://myurl/hodtv_live/_definst_/doConnect=connecttoken&livestream.file=live.sdp
<Property> <Name>secureTokenSharedSecret</Name> <Value>verysecret</Value> </Property> <Property> <Name>secureurlparams.connect</Name> <Value>connecttoken.doConnect</Value> </Property> <Property> <Name>secureurlparams.publish</Name> <Value>Tokenpub.doPublish</Value> </Property>
package com.jeroenwijering.plugins { import com.jeroenwijering.events.*; import com.jeroenwijering.utils.Logger; import flash.display.*; import flash.events.*; import flash.net.*; import flash.utils.setTimeout; import flash.text.*; /** * This plugin automatically polls an RTMP stream for availability every XX seconds. * If the stream is available, it will kick in. * It allows users to wait for a live event without having to refresh their page. **/ public class Livestream extends MovieClip implements PluginInterface { [Embed(source="../../../animation.swf")] private const Animation:Class; /** Background image. **/ private var back:Sprite; /** List with configuration settings. **/ public var config:Object = { file:undefined, image:undefined, interval:15, message:'Checking for livestream...', streamer:undefined, tags:undefined }; /** Netconnection instance to check availability. **/ private var connection:NetConnection; /** The number times the plugin tried to connect. **/ private var count:Number = 0; /** The textfield showing all messages. **/ private var field:TextField; /** Netstream instance to check availability. **/ private var stream:NetStream; /** Reference to the view. **/ private var view:AbstractView; /** Constructor. **/ public function Livestream():void { connection = new NetConnection(); buildStage(); }; /** Build all stage graphics. **/ private function buildStage():void { back = new Sprite(); back.graphics.beginFill(0x000000,0.6); back.graphics.drawRect(0,0,300,70); addChild(back); var anm:DisplayObject = new Animation(); anm.x = 134; anm.y = 10; addChild(anm); field = new TextField(); field.defaultTextFormat = new TextFormat('_sans',13,0xFFFFFF,null,null,null,null,null,TextFormatAlign.CENTER); field.width = 300; field.height = 20; field.y = 45; addChild(field); mouseEnabled = false; visible = false; }; /** Try connecting to the livestream. **/ private function checkStream():void { count++; connection.addEventListener(NetStatusEvent.NET_STATUS,statusHandler); connection.connect(config['streamer']); visible = true; setTimeout(hide,2000); Logger.log('checking for stream; attempt: '+count,'livestream'); }; /** Hide the icon again after a check. **/ private function hide():void { visible = false; }; /** * Start the plugin. * * @param vie A reference to the View of the player; the API entrypoint. **/ public function initializePlugin(vie:AbstractView):void { view = vie; if(!config['tags'] || config['tags'] == view.config['tags']) { view.config['icons'] = false; view.config['repeat'] = 'always'; setTimeout(checkStream,2000); view.addControllerListener(ControllerEvent.RESIZE,resizeHandler); field.text = config['message']; } }; /** The livestream is found. Now switch to it. **/ private function loadStream():void { view.config['autostart'] = true; view.config['icons'] = true; view.config['repeat'] = 'none'; var obj:Object = { duration:0, file:config['file'], image:config['image'], streamer:config['streamer'], type:'rtmp' } view.sendEvent('LOAD',obj); }; /** Reposition the icon on resize. **/ private function resizeHandler(evt:ControllerEvent):void { x = config['x'] + config['width']/2 - 150; y = config['y'] + config['height']/2 - 35; }; /** Receive NetStream status updates. **/ private function statusHandler(evt:NetStatusEvent):void { switch(evt.info.code) { case 'NetConnection.Connect.Success': stream = new NetStream(connection); stream.client = new Object(); stream.addEventListener(NetStatusEvent.NET_STATUS,statusHandler); stream.play(config['file']); Logger.log('connected to server '+config['streamer'],'livestream'); break; case 'NetStream.Play.Start': stream.removeEventListener(NetStatusEvent.NET_STATUS,statusHandler); connection.removeEventListener(NetStatusEvent.NET_STATUS,statusHandler); stream.close(); connection.close(); setTimeout(loadStream,2000); Logger.log('found stream '+config['file'],'livestream'); break; case 'NetStream.Play.StreamNotFound': case 'NetConnection.Connect.Failed': stream.removeEventListener(NetStatusEvent.NET_STATUS,statusHandler); connection.removeEventListener(NetStatusEvent.NET_STATUS,statusHandler); setTimeout(checkStream,config['interval']*1000); Logger.log('no livestream yet: '+evt.info.code,'livestream'); break; } }; }; }
Answer by Richard Lanham · Aug 01, 2009 at 01:12 PM
<Name>secureTokenSharedSecret</Name> <Value>verysecret</Value> </Property>
Answer by Richard Lanham · Aug 01, 2009 at 02:15 PM
Answer by Richard Lanham · Aug 01, 2009 at 02:47 PM
Answer by Richard Lanham · Aug 17, 2009 at 12:17 PM
/** Receive NetStream status updates. **/
private function statusHandler(evt:NetStatusEvent):void {
switch(evt.info.code) {
case 'NetConnection.Connect.Success':
// ADD THESE LINES:
if (evt.info.secureToken != undefined) //<--- SecureToken change here - respond with decoded secureToken
{
netconnection.call("secureTokenResponse", null, TEA.decrypt(evt.info.secureToken,"#ed%h0#w@1"));
}
stream = new NetStream(connection);
stream.client = new Object();
stream.addEventListener(NetStatusEvent.NET_STATUS,statusHandler);
stream.play(config['file']);
Logger.log('connected to server '+config['streamer'],'livestream');
break;
case 'NetStream.Play.Start':
stream.removeEventListener(NetStatusEvent.NET_STATUS,statusHandler);
connection.removeEventListener(NetStatusEvent.NET_STATUS,statusHandler);
stream.close();
connection.close();
setTimeout(loadStream,2000);
Logger.log('found stream '+config['file'],'livestream');
break;
case 'NetStream.Play.StreamNotFound':
case 'NetConnection.Connect.Failed':
stream.removeEventListener(NetStatusEvent.NET_STATUS,statusHandler);
connection.removeEventListener(NetStatusEvent.NET_STATUS,statusHandler);
setTimeout(checkStream,config['interval']*1000);
Logger.log('no livestream yet: '+evt.info.code,'livestream');
break;
}
};
Answer by Josh Chesarek · Aug 02, 2009 at 12:31 PM
© 2005–2018 Wowza Media Systems, LLC. All rights reserved. Terms | Privacy | Trademarks | Legal