Create pseudo-live streams using files
Create pseudo-live streams using files available to the application with a Wowza Streaming Engine server listener
Updated on 07/16/2026 8:48 am PDT
The following StreamPublisher example shows how to create a server listener with the Wowza Streaming Engine™ Java API that uses the Stream class functionality to create pseudo-live streams using files available to the application publishing the streams.
- Compile the following server listener in the Wowza IDE:
Copy
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)
{
}
}
- Add the server listener to /conf/Server.xml /ServerListeners:
Copy
<ServerListener>
<BaseClass>com.wowza.forum.StreamPublisher</BaseClass>
</ServerListener>
- Create a live application named live (with the StreamType property in the
container element in [ install-dir]/live/Application.xml set to live) if one does not already exist.
The Stream class functionality provides the ability to add files or streams that will be played sequentially or looped based on configuration of each entry.
In the above example, the play function takes the following arguments:
- play (string filename, int startTime, int length, Boolean reset)
- filename - name of media item
- start - where to start playing the item. ( -2 implies play a live stream)
- length - how much of the item to play ( -1 implies play the entire file or live stream)
- reset - if true, will begin a new playlist, otherwise items are appended
If adding a live stream then the next item will not be played without interaction with the API.
Was this article helpful?
[Helpful](/content/docs/stream-class-example# "Helpful"/index.html)
Thank you for your feedback!
300 characters remaining
Name
reCAPTCHA
Recaptcha requires verification.
I'm not a robot
reCAPTCHA
[Submit](/content/docs/stream-class-example# "Submit comment"/index.html)
Thank you for providing feedback to help us improve our documentation!
Popular Video Topics [Copy to clipboard](/content/docs/stream-class-example#popular-video-topics "Copy to clipboard"/index.html)
- The Future of Video Tech
- Streaming Starter Guide
- Live Event Streaming Guide
- Interactive Streaming Guide
- Streaming Protocols
- Transcoding
- Low Latency
- Security
Video Resources [Copy to clipboard](/content/docs/stream-class-example#video-resources "Copy to clipboard"/index.html)
Partners [Copy to clipboard](/content/docs/stream-class-example#partners "Copy to clipboard"/index.html)
Company [Copy to clipboard](/content/docs/stream-class-example#company "Copy to clipboard"/index.html)
Stay Connected [Copy to clipboard](/content/docs/stream-class-example#stay-connected "Copy to clipboard"/index.html)
Stay Up to Date with the Blog [Copy to clipboard](/content/docs/stream-class-example#stay-up-to-date-with-the-blog "Copy to clipboard"/index.html)
X - Form Filled Type
© 2007–2025 Wowza Media Systems™, LLC. All rights reserved. Security & Privacy Policy | Legal | System Status
reCAPTCHA