Wowza Community

Livestream plugin and jwplayer

I’m trying to get the livestream plugin from jwplayer to work with my wowza stream.

my stream has a security token and it looks like the plugin doesnt handle that.

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

my livestream code is :

livestream.streamer=rtmp://myurl/hodtv_live/_definst_/doConnect=connecttoken&livestream.file=live.sdp

this is my application

<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>

the stream works perfect with just jw-player and token build in the source code.

here is the source for livestream plugin:

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;
		}
	};
};
}

Does anyone know how to fix this problem? couse i think this plugin is very usefull for livestreamers

Grz

Terrorhawk

Make sure you are only using the SecureURLParams module, which includes the functionality of SecureToken. If you have both, that could be a problem. See note at bottom of package readme.html

From what I can see it looks right.

I would try it with plain JW Player without plugin, see if that works first.

Richard

I’m wonder if this plug-in is actually useful with Wowza. All it does is poll for a live stream if it does not exist when play starts, and will play it when it publishes. But I think JW player will do that without the polling mechanism (?)

Richard

Okay, that makes sense. Nice feature if it works.

I think you are right, you will have to put the secureToken in the plugin, because the connection is established and handled in the plugin.

Richard

Try it like this:

/** 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;

}

};

Richard

Also noticing that you are using secureURLParams (doConnect). You don’t need it and it will be a problem to include the ampersand “&” in stream Flashvar

Just use SecureToken.

Richard

I just re-read this question about live and will have to play with it a little. Sorry about that.

without thw plugin it works perfect.

only when i activate the plugin i get that error message… so my gues is that it has something to do with the token

 <Name>secureTokenSharedSecret</Name> 
  <Value>verysecret</Value> 
 </Property> 

in jw palyer itself i enterd the verysecret as token in the source code. but i think i need to do that with the livestream plugin as well. as it also tryes to connect.

But i’m realy not good with flash and its actionscript

well i’m using 2 stream…

1 live stream and one stream that is localy streamed to wowza with vlc ffor not live events…

So jwplayer sould play not_live but if some dj starts stream at live it sould make the switch to that stream… and when live is gone it sould go back to not_live

And as far as i know this plugin sould do the job

yes i notice that… but do u know how to implent that token to the plugin?

if we can fix that then this is a great plugin for me and i think other users as well.

i realy only know some basic things in as3 but that token for connection is going to far for me…

nobody know how to add the serurity token to this plugin?