# Schedule a live stream to run for x seconds

**URL:** <https://community.wowza.com/t/schedule-a-live-stream-to-run-for-x-seconds/33608>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [October 27, 2014, 11:35am UTC](https://community.wowza.com/t/schedule-a-live-stream-to-run-for-x-seconds/33608 "2014-10-27T11:35:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karel\_Boek](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/karel_boek/32/454_2.png) [@Karel\_Boek](https://community.wowza.com/u/Karel_Boek)\
**Post date:** [October 27, 2014, 11:35am UTC](https://community.wowza.com/t/schedule-a-live-stream-to-run-for-x-seconds/33608/1 "2014-10-27T11:35:26Z")

</div>

I’m creating a scheduler that can start a live stream at a defined date/time. Using the ServerListenerStreamPublisher as a starting point, I use the following code to create the playlist and start playing:

```auto
private class StreamListener implements IStreamActionNotify {
  @Override
  public void onPlaylistItemStart(Stream stream, PlaylistItem playlistItem) {
    WMSLoggerFactory.getLogger(null).info("PlaylistItem started");
  }
  @Override
  public void onPlaylistItemStop(Stream stream, PlaylistItem playlistItem) {
    WMSLoggerFactory.getLogger(null).info("PlaylistItem stopped");
  }
}
Stream stream = Stream.createInstance(appInstance, streamname);
stream.addListener( new StreamListener() );
Playlist playlist = new Playlist("mytest");
playlist.addItem("udp://127.0.0.1:1234", -2, 3600);
playlist.open(stream);

```

As you can see, I’m trying to play this live stream for exactly one hour. To my surprise, I see that the StreamListener.onPlaylistItemStart and StreamListener.onPlaylistItemStop get called directly after each other. This happens only when the source is a live stream (I also tried with a .stream file, same result) - when I try it with sample.mp4, it works as expected.

My intention is to use the startMediaCasterStream/stopMediaCasterStream inside onPlaylistItemStart/onPlaylistItemStop

Is this behavior as designed?

---

<div class="post-metadata">

**Author:** ![Matt\_Young](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/matt_young/32/389_2.png) [@Matt\_Young](https://community.wowza.com/u/Matt_Young)\
**Post date:** [October 28, 2014, 6:21am UTC](https://community.wowza.com/t/schedule-a-live-stream-to-run-for-x-seconds/33608/2 "2014-10-28T06:21:04Z")

</div>

Refer to ticket #107444
