# Livestream plugin and jwplayer

**URL:** <https://community.wowza.com/t/livestream-plugin-and-jwplayer/712>\
**Category:** Wowza Streaming Engine\
**Created:** [August 1, 2009, 8:09am UTC](https://community.wowza.com/t/livestream-plugin-and-jwplayer/712 "2009-08-01T08:09:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/system/32/447_2.png) [@system](https://community.wowza.com/u/system)\
**Post date:** [August 1, 2009, 8:09am UTC](https://community.wowza.com/t/livestream-plugin-and-jwplayer/712/1 "2009-08-01T08:09:25Z")

</div>

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.

```auto
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 :

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

```

this is my application

```auto
<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:

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

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [August 1, 2009, 1:12pm UTC](https://community.wowza.com/t/livestream-plugin-and-jwplayer/712/2 "2009-08-01T13:12:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [August 1, 2009, 2:15pm UTC](https://community.wowza.com/t/livestream-plugin-and-jwplayer/712/3 "2009-08-01T14:15:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [August 1, 2009, 2:47pm UTC](https://community.wowza.com/t/livestream-plugin-and-jwplayer/712/4 "2009-08-01T14:47:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [August 17, 2009, 12:17pm UTC](https://community.wowza.com/t/livestream-plugin-and-jwplayer/712/5 "2009-08-17T12:17:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [August 17, 2009, 12:27pm UTC](https://community.wowza.com/t/livestream-plugin-and-jwplayer/712/6 "2009-08-17T12:27:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Josh\_Chesarek](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@Josh\_Chesarek](https://community.wowza.com/u/Josh_Chesarek)\
**Post date:** [August 2, 2009, 12:31pm UTC](https://community.wowza.com/t/livestream-plugin-and-jwplayer/712/7 "2009-08-02T12:31:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![John\_Terrorhawk](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@John\_Terrorhawk](https://community.wowza.com/u/John_Terrorhawk)\
**Post date:** [August 1, 2009, 3:07pm UTC](https://community.wowza.com/t/livestream-plugin-and-jwplayer/712/8 "2009-08-01T15:07:15Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![John\_Terrorhawk](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@John\_Terrorhawk](https://community.wowza.com/u/John_Terrorhawk)\
**Post date:** [August 1, 2009, 3:45pm UTC](https://community.wowza.com/t/livestream-plugin-and-jwplayer/712/9 "2009-08-01T15:45:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![John\_Terrorhawk](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@John\_Terrorhawk](https://community.wowza.com/u/John_Terrorhawk)\
**Post date:** [August 1, 2009, 4:16pm UTC](https://community.wowza.com/t/livestream-plugin-and-jwplayer/712/10 "2009-08-01T16:16:47Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![John\_Terrorhawk](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@John\_Terrorhawk](https://community.wowza.com/u/John_Terrorhawk)\
**Post date:** [August 17, 2009, 11:39am UTC](https://community.wowza.com/t/livestream-plugin-and-jwplayer/712/11 "2009-08-17T11:39:21Z")

</div>

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