You can use this module along with the Stream class scheduler. The Streams and Playlists that you set up in the schedule can be modified and controlled using this application.
A pre-built version of the following module is included in the Wowza Modules Collection
Code:
package com.wowza.wms.plugin.collection.module;
import com.wowza.wms.amf.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;
import com.wowza.wms.stream.publish.*;
public class ModuleStreamControl extends ModuleBase {
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);
playlist.open(stream);
}
public void addItemToPlaylist(IClient client, RequestFunction function,
AMFDataList params) {
AMFDataObj obj = getParamObj(params, PARAM1);
Playlist playlist = (Playlist)client.getAppInstance().getProperties().getProperty(obj.getString("playListName"));
playlist.addItem(obj.getString("itemName"), obj.getInt("itemStart"), obj.getInt("itemDuration"));
}
public void playNextPlaylistItem(IClient client, RequestFunction function,
AMFDataList params) {
String streamName = getParamString(params, PARAM1);
Stream stream = (Stream)client.getAppInstance().getProperties().getProperty(streamName);
stream.next();
}
public void addNewStream(IClient client, RequestFunction function,
AMFDataList params) {
String streamName = getParamString(params, PARAM1);
Stream stream = Stream.createInstance(client.getAppInstance(), streamName);
client.getAppInstance().getProperties().put(streamName, stream);
}
public void addNewPlaylist(IClient client, RequestFunction function,
AMFDataList params) {
String playListName = getParamString(params, PARAM1);
Playlist playlist = new Playlist(playListName);
playlist.setRepeat(true);
client.getAppInstance().getProperties().put(playListName, playlist);
}
public void stopStream(IClient client, RequestFunction function,
AMFDataList params) {
String streamName = getParamString(params, PARAM1);
Stream stream = (Stream)client.getAppInstance().getProperties().remove(streamName);
if(stream != null)
stream.close();
}
}
(There is a modified version of the Wowza LiveVideoStreaming player with these commands here: http://www.wowzamedia.com/downloads/...assControl.zip. See below for instructions.)
Code:
public function addNewStream():void
{
nc.call("addNewStream",null,streamName.text);
}
public function addNewPlaylist():void
{
nc.call("addNewPlaylist",null,playlist.text);
}
public function stopStream():void
{
nc.call("stopStream",null,streamName.text);
}
public function openPlaylistOnStream():void
{
nc.call("openPlaylistOnStream",null,streamName.text,playlist.text);
}
public function nextItem():void
{
nc.call("playNextPlaylistItem",null,streamName.text);
}
public function addItemToPlaylist():void
{
var obj:Object = new Object();
obj.playListName = playlist.text;
obj.itemName = itemName.text;
obj.itemStart = itemStart.text;
obj.itemDuration = itemDuration.text;
nc.call("addItemToPlaylist",null,obj);
}
Code:
<Module> <Name>streamcontroller</Name> <Description>ModuleStreamControl</Description> <Class>com.wowza.wms.plugin.collection.module.ModuleStreamControl</Class> </Module>
This is a modified version of Wowza Live Player with these features.
To operate, use the buttons and textinput below the the video display
- Enter a Stream (I filled in "StreamNew"), then click "add stream"
- Enter a Playlist (I filled in "playlistNew"), then click "add playlist"
- Add at least one item to the playlist (I filled in "mp4:sample.mp4" with start of 0 and length -1), click "add Item to playlist"
- Then click "open playlist on stream"
- Then in above, enter the streamname, "StreamNew" and click "Play"
To add a new item, enter a new video name with start and length, and click "add item to playlist", then click open "open playlist on stream again". If the video is currently playing, the new item will start playing after the current one or when it cycles through to the end. You can also click "play next item"
The Stream Control application module and client provide no feedback or listing of active streams. If you are using with the scheduler you have to know what stream name and playlist name to use.
To add a live stream to a playlist enter "-2" for Video start. You can mix live streams and static content. You can use MediaCaster streams, but be sure to start them using /conf/StartupStreams.xml or in a application module or server listener using MediaCasterStreamManager.
I set the buffer to 0 for the playback in the provided client app for the moment. Buffer time in the client is a big factor in what the user sees when streams switch.


Article List
Categories
Wowza Media