Do basic server-side publishing with stream class and

Do basic server-side publishing with the Stream class and Wowza Streaming Engine Java API

Updated on 07/16/2026 8:30 am PDT

Use the Stream class to publish live streams using static content. You can also publish on a schedule, like a television station.

This example illustrates basic use of the Stream class:

Copy

package com.wowza.wms.example.serverlistener;

import com.wowza.wms.logging.WMSLoggerFactory;
import com.wowza.wms.server.*;
import com.wowza.wms.vhost.*;
import com.wowza.wms.stream.publish.*;
import com.wowza.wms.application.*;

public class StreamPublisherDemo implements IServerNotify2 {

public void onServerConfigLoaded(IServer server)
    {
    }

public void onServerCreate(IServer server)
    {
    }

public void onServerInit(IServer server)
    {
        IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
        IApplication app = vhost.getApplication("live");
        IApplicationInstance appInstance = app.getAppInstance("_definst_");

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);
        stream1.addListener(new StreamListener(appInstance));

Stream stream2 = Stream.createInstance(vhost, "live", "Stream2");

stream2.play("mp4:sample.mp4", 0, -1, true);
        stream2.addListener(new StreamListener(appInstance));

}

public void onServerShutdownStart(IServer server)
    {
    }

public void onServerShutdownComplete(IServer server)
    {
    }

class StreamListener implements IStreamActionNotify
    {
        StreamListener(IApplicationInstance appInstance)
        {
        }
        public void onPlaylistItemStop(Stream stream, PlaylistItem item)
        {
            WMSLoggerFactory.getLogger(null).info("Item Stopped: " + item.getName() + "on Stream: " + stream.getName());
        }
        public void onPlaylistItemStart(Stream stream, PlaylistItem item)
        {
            WMSLoggerFactory.getLogger(null).info("Item Started: " + item.getName() + "on Stream: " + stream.getName());
        }
    }
}

Add the server listener to /conf/Server.xml /ServerListeners:

Copy

    <ServerListener>
        <BaseClass>com.wowza.wms.example.serverlistener.StreamPublisherDemo</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.

Was this article helpful?

[Helpful](/content/docs/how-to-do-basic-server-side-publishing-with-stream-class-streams# "Helpful"/index.html)

Thank you for your feedback!

300 characters remaining

Name

Email

reCAPTCHA

Recaptcha requires verification.

I'm not a robot

reCAPTCHA

[Submit](/content/docs/how-to-do-basic-server-side-publishing-with-stream-class-streams# "Submit comment"/index.html)

Thank you for providing feedback to help us improve our documentation!

Popular Video Topics [Copy to clipboard](/content/docs/how-to-do-basic-server-side-publishing-with-stream-class-streams#popular-video-topics "Copy to clipboard"/index.html)
Video Resources [Copy to clipboard](/content/docs/how-to-do-basic-server-side-publishing-with-stream-class-streams#video-resources "Copy to clipboard"/index.html)
Partners [Copy to clipboard](/content/docs/how-to-do-basic-server-side-publishing-with-stream-class-streams#partners "Copy to clipboard"/index.html)
Company [Copy to clipboard](/content/docs/how-to-do-basic-server-side-publishing-with-stream-class-streams#company "Copy to clipboard"/index.html)
Stay Connected [Copy to clipboard](/content/docs/how-to-do-basic-server-side-publishing-with-stream-class-streams#stay-connected "Copy to clipboard"/index.html)
Stay Up to Date with the Blog [Copy to clipboard](/content/docs/how-to-do-basic-server-side-publishing-with-stream-class-streams#stay-up-to-date-with-the-blog "Copy to clipboard"/index.html)

Email

X - Form Filled Type

© 2007–2025 Wowza Media Systems™, LLC. All rights reserved.   Security & Privacy Policy | Legal | System Status

reCAPTCHA