(Compact version)
Code to inject a cue point that gets recorded and triggered client side from the server side.
Note this requires Wowza Server 2.0.0.15 (patch 15) or higher
package com.wowza.example.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.*;
public class ModuleInjectCuePoint extends ModuleBase {
public void setCaption (IClient client, RequestFunction function, AMFDataList params)
{
String streamname = params.getString(PARAM1);
String caption = params.getString(PARAM2);
IMediaStream stream = client.getAppInstance().getStreams().getStream(streamname);
//essential code
AMFDataMixedArray data = new AMFDataMixedArray();
data.put("caption", new AMFDataItem(capton);
stream.sendDirect("setCaption", data);
getLogger().info("Caption: " + caption);
}
}
Flash Client 1, Live stream player with controls to inject the caption
// call the function:
netconnection.call("setCaption",null,"myStream","hello room");
// set up netstream for the callback on the live stream
nsPlayClientObj:Object = new Object();
nsPlayClientObj.setCaption = function(caption:String):void
{
trace(caption);
}
nsPlay.client = nsPlayClientObj;
Flash Client 2, a vod player
// set up netstream for callback on recorded stream
var nsPlayClientObj:Object = new Object();
nsPlayClientObj.setCaption = function(obj:Object):void
{
trace(obj.caption)
}
nsPlay.client = nsPlayClientObj;