而不是單身人士,如果您的視頻聊天時間一旦開始聊天就不會改變,您可以實現一個模塊並在play
或publish
事件上附加TimerTask
。以下是您幫助您入門的一個示例。
import java.util.Timer;
import java.util.TimerTask;
import com.wowza.wms.amf.AMFDataList;
import com.wowza.wms.client.IClient;
import com.wowza.wms.logging.WMSLogger;
import com.wowza.wms.module.*;
import com.wowza.wms.request.RequestFunction;
import com.wowza.wms.stream.IMediaStream;
import com.wowza.wms.stream.IMediaStreamActionNotify;
public class KillAfterNSeconds extends ModuleBase implements IMediaStreamActionNotify {
private class StreamKiller extends TimerTask{
private IMediaStream stream;
public StreamKiller(IMediaStream s){
this.stream = s;
}
@Override
public void run() {
try{
// Complete all your clean up, such as :
if(stream != null){
WMSLogger.getLogger("").info("Killing stream: " + stream.getName());
stream.getClient().shutdownClient();
stream.shutdown();
stream.close();
}
}catch(Exception e){}
}
}
public void publish(IClient paramIClient,
RequestFunction paramRequestFunction, AMFDataList paramAMFDataList) {
WMSLogger.getLogger("").info("Start running publish..");
IMediaStream stream = getStream(paramIClient, paramRequestFunction);
stream.addClientListener(this);
Timer timer = new Timer();
TimerTask task = new StreamKiller(stream);
// replace here with the actual time to kill stream
timer.schedule(task, 10000);
invokePrevious(paramIClient, paramRequestFunction, paramAMFDataList);
WMSLogger.getLogger("").info("Finish running publish..");
return;
}
@Override
public void onUnPublish(IMediaStream stream, String streamName,
boolean isRecord, boolean isAppend) {
WMSLogger.getLogger("").info("Start onUnPublish..");
double elapSeconds = stream.getElapsedTime().getTimeSeconds();
WMSLogger.getLogger("").info("Elapsed time " + elapSeconds);
WMSLogger.getLogger("").info("Finish running onUnPublish..");
}
@Override
public void onPause(IMediaStream arg0, boolean arg1, double arg2) {
}
@Override
public void onPlay(IMediaStream arg0, String arg1, double arg2,
double arg3, int arg4) {
}
@Override
public void onPublish(IMediaStream arg0, String arg1, boolean arg2,
boolean arg3) {
}
@Override
public void onSeek(IMediaStream arg0, double arg1) {
}
@Override
public void onStop(IMediaStream arg0) {
}
}
您是否嘗試過在Wowza支持論壇發佈該問題?他們相當有幫助。 – Salman
我會試一試。謝謝你的提示。 – nahri