Wowza Community

Stream class stream controller

In the following function of openPlaylistOnStream, I do not know how to handle exception. It assumes the stream/file in the playlist is available. But this is not always the case. I hope it will raise some exception when the file is deleted or the live stream is not published yet.

I did find that for a live stream, if it is not published yet, it will start playing once the live stream is published. But if it can raise some exception, I think developer may need that for some handling. For my case, the streaming just hangs on one frame of last static video and waits there. This is not good. I hope it continues playing the static video and alerts a warning that live streaming is not published yet. And for static video, the same. I have two sets of static video, one is uploaded by the customer, one is the system default. Customers usually forget their videos or deleted their videos, if I can detect an exception while opening playlist on stream, I will let the progam automatically switch to my system default, which is usually there.

What I am asking is that will raise exceptions in one way or another. Please consider my requirement.

public void openPlaylistOnStream(IClient client, RequestFunction function, AMFDataList params) {

String streamName = getParamString(params, PARAM1);

String playlistName = getParamString(params, PARAM2);

Stream stream = (Stream)client.getAppInstance().getProperties().getProperty(streamName);

Playlist playlist = (Playlist)client.getAppInstance().getProperties().getProperty(playlistName);;


When using LiveStudio.html I ran into 2 problems.

  1. I got this security issue:

SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller file:///C:/Wowza2.1.1_Development/examples/StreamClassControl/LiveStudio.swf cannot access file:///C:/Wowza2.1.1_Development/examples/StreamClassControl/LiveStudio.html.

  1. How can I add my secureToken’s shared secret? I changed in the shared secret. But how to compile?

Maybe somebody else can help me.

I’m able to compile into LifeStudio.swf and LiveStudio.mxml into LifeStudio.swf. But both have a much smaller filesize than the original LiveStudio.swf. So I assume that something is wrong.

How do the 2 files ( & LiveStudio.mxml) relate to each other? Do I need to compile both or only one?

I only want to change the shared secret and get a new swf file.

Is the source code of class ModuleStreamControl at the beginning of the thread the latest u have? Is it updated?

Also, to your 1st question: yes, you can remove a PlaylistItem like this:

Boolean success = stream.removeFromPlaylist("Extremists.flv");


This I dont understand.

Shouldn’t be instead of “Extremists.flv” a stream name?

In the docu it says:

Remove all items matching the given stream name from the playlist.

But a playlist is only attached to one stream anyway. Isn’t it?

These all I understood.

But what about my questions?

I’m back with this functionality, and would appreciate this next way of implementation.

First some background on our setup. We have an “automation” server that runs services based on the request. It is built in Java (if that matters for this or not) and we are looking to have this stream controller class perform specific actions request by our automation services.

We need to be able to “talk” to the wowza server from our automation server by sending things such as nextItem(wowzaIP,myStream2,indexNum,startTime,lengthTime) to the specific wowza server’s ip. Is there a simple implementation for this type of action to be handled or a set of other modules that need to be installed for this type of communication?

Hi guys,

I’m testing this with a local Developer’s WMS. I like the idea of having a “channel” playing saved videos and being able to “push” live streams on demand. So far I have the playlist (A.K.A. SMIL file) working with the LiveStudio.html player but when I try to “push” a live stream from Wirecast into the playlist, I get null errors in the server’s console:

ERROR server comment - invoke(addItemToPlaylist): java.lang.NullPointerException: com.wowza.wms.plugin.collection.module.ModuleStreamControl.addItemTo



at com.wowza.wms.plugin.collection.module.ModuleStreamControl.addItemToPlaylist(

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(

at sun.reflect.DelegatingMethodAccessorImpl.invoke(

at java.lang.reflect.Method.invoke(

at com.wowza.wms.module.ModuleFunction.invoke(Unknown Source)

at com.wowza.wms.module.ModuleFunctions.invoke(Unknown Source)

at com.wowza.wms.request.RequestProcessFunctions.processFunctions(Unknown Source)

at com.wowza.wms.client.ClientWorker.processNextReq(Unknown Source)

at com.wowza.wms.request.RTMPRequestAdapter.service(Unknown Source)

at com.wowza.wms.server.ServerHandler.serviceRequest(Unknown Source)

at com.wowza.wms.server.ServerHandler.handleMessageReceived(Unknown Source)

at com.wowza.wms.server.ServerHandler.messageReceived(Unknown Source)

at Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(

at java.util.concurrent.ThreadPoolExecutor$


I’m doing the following:

In my SMIL file I have:

and I load it in LiveStudio.html as:

Server: rtmp://localhost/live

Stream: Stream1

Click “Connect” then click “Play” and the playlist plays fine. Then I add the following into the bottom controls:

Stream: Stream1

Playlist: pl1

add item to playlist: liveStream.flv 0 -2 (liveStream is the name of my live stream from Wirecast)

And when I hit the button “add item to playlist” the error pops up in the server’s console. The playlist isn’t interrupted or anything.

My live/Application.xml is set to live-record and I added the streamcontroller module.

What might be the problem?

Thanks in advance!

Hi Richard,

Thanks for your reply. I’m mixing stream file types just for testing… in the production server, only .flv files will be used. Thanks for the tip :wink:

Anyway, back to the issue. I changed my SMIL file to be like this:

        <stream name="Stream1"></stream>
        <playlist name="pl1" playOnStream="Stream1" repeat="true" scheduled="2009-12-11 16:25:30">
            <video src="flv:liveStream_0.flv" start="0" length="15" />
            <video src="mp4:Extremists.m4v" start="0" length="15" />
            <video src="liveStream" start="-2" length="-1" />

but now only the live stream is played and when I stop the live feed, the player stops instead of resuming the regular “channel” (saved videos) which is my goal. I would need ppl to watch the channel and suddenly start watching the live feed without refreshing their browsers. Is this possible using this module? How should I write my SMIL file?

Thanks again,

All right, I see what you mean. I think it could be possible if the controller app was running ok.

Anyways do you know any other mods that could be used (alone or together) to achieve this? Or maybe with this same module but setting up my SMIL differently?

Thanks again.

Ok, I found the following here:

The easiest solution is to send a command to all the connected clients that tells them to play a different stream. Use the appInstance.broadcastMsg() method. Then when the stream is available again, send the same message to the clients to have them switch back to the live stream.

Server side:

appInstance.broadcastMsg("switchToStream", streamName);

Client side (AS2):

nc.switchToStream = function(streamName)

Server side, use a Thread that sits in a loose sleep loop that uses the Date function to check the time and triggers the event:

Another solution is to disconnect all clients whent the live feed is over. You can do this with a call to IClient.setShutdownClient(true) for each of the connected clients. Next, add code to the client side that does a reconnect on disconnect. When they reconnect have them reconnect to a different stream.

Take a look at this article. It discusses a method for scheduling event triggers:

This is straight forward. Trying to mess with redirecting packets server side is just going to get complicated.

I hope this helps.


This is just what I need. My only question is: How can I instruct my WMS appInstance.broadcastMsg(“switchToStream”, streamName); ?

Charlie is talking about a loop that makes that call at HH:MM:SS but I would need to call it by hand. My show won’t be live at the same hour every day and won’t last exactly the same each time.

If I could call that function by hand, I could force all the connected clients to watch my live feed and then call the function again so they can continue watching recorded media.

It would also be great if WMS could execute that function (using different stream names) when it detects a live feed and again when the live feed is over. Is that possible? makes exaclty that… how do they do it? What’s the magic trick?

Thanks in advance,