• Stream Class Example

    This article shows a Stream class example.

    1. Compile the following server listener in the Wowza IDE:
      package com.wowza.forum;
      
      import com.wowza.wms.server.*;
      import com.wowza.wms.vhost.*;
      import com.wowza.wms.stream.publish.*;
      
      public class StreamPublisher implements IServerNotify {
      
      	public void onServerCreate(IServer server)
      	{
      	}
      	public void onServerInit(IServer server)
      	{
      		IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
      		
      		Stream stream1 = Stream.createInstance(vhost, "live", "Stream1");
      		stream1.play("mp4:sample.mp4", 5, 5, true);
      		stream1.play("mp4:sample.mp4", 50, 5, false);
      		stream1.play("mp4:sample.mp4", 150, 5, false);
      		
      		Stream stream2 = Stream.createInstance(vhost, "live", "Stream2");
      		stream2.play("mp4:sample.mp4", 0, -1, true);
      	}
      
      	public void onServerShutdownComplete(IServer server)
      	{
      	}
      
      	public void onServerShutdownStart(IServer server)
      	{
      	}
      }
    2. Add the server listener to /conf/Server.xml /ServerListeners:
      <ServerListener>
      		<BaseClass>com.wowza.forum.StreamPublisher</BaseClass>
      	</ServerListener>
    3. Create a Wowza application named live and change the Application.xml /StreamType to live.

    4. To play, open:

      [install-dir]/examples/LiveVideoStreaming/FlashRTMPPlayer/player.html (Wowza Media Server 3.5 and later)

      -or-

      [install-dir]/examples/LiveVideoStreaming/client/live.html (prior version of Wowza Media Server)

      Server: rtmp://[wowza-ip-address]/live
      Stream: Stream1 (or Stream2)

    Originally Published: 10-03-2010.

    If you're having problems or want to discuss this article, post in our forum.