• How to override play to control access

    Short code snippet to show how to override the play command to control access to content. Each call from the Flash player to play content will be intercepted by this module. You can then decide to let the play occur or return an error onStatus message back to the player.

    Code:
    package com.wowza.wms.plugin.test.module;
    
    import java.util.*; 
    
    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.*;
    import com.wowza.wms.application.*;
    
    public class ModuleOverrideExample extends ModuleBase
    {
    	public void play(IClient client, RequestFunction function, AMFDataList params)
    	{
    		boolean doit = true;
    		IMediaStream stream = getStream(client, function);		
    		String streamName = getParamString(params, PARAM1);
    
    		// check to see if client should be allowed to play content
    		doit = false;
    		
    		if (doit)
    			invokePrevious(this, client, function, params);
    		else
    			sendStreamOnStatusError(stream, "NetStream.Play.Failed", "Access denied: "+streamName);
    	}
    }
    Here is another example that illustrates how to change the stream name:

    Code:
    package com.wowza.wms.plugin.test.module;
    
    import java.util.*;
    
    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.*;
    import com.wowza.wms.application.*;
    
    public class ModuleOverrideExample extends ModuleBase
    {
    	public void play(IClient client, RequestFunction function, AMFDataList params)
    	{
    		String streamName = getParamString(params, PARAM1);
    
    		// change stream name here
    		String newName = streamName;
    		params.set(PARAM1, new AMFDataItem(newName));
    
    		invokePrevious(this, client, function, params);
    	}
    }

    Comments 3 Comments
    1. woutdec -
      How can you achieve this (rename a stream at request) using HTTP cupertino streaming? The play() method seems to get skipped. Thanks.
    1. shamrock -
      See article here

      http://www.wowzamedia.com/forums/con...der2-interface

      which shows how to intercept all requests for streaming.

      Shamrock
    1. woutdec -
      Great, that seems to be what I was looking for. Thank you.