# HLS live streams loop forever?

**URL:** https://community.wowza.com/t/hls-live-streams-loop-forever/43942
**Category:** Wowza Developer Dojo
**Tags:** wowza-streaming-server-java-api
**Created:** [August 8, 2016, 4:08pm UTC](https://community.wowza.com/t/hls-live-streams-loop-forever/43942 "2016-08-08T16:08:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jim\_Houseman](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@Jim\_Houseman](https://community.wowza.com/u/Jim_Houseman)
#### Post date: [August 8, 2016, 4:08pm UTC](https://community.wowza.com/t/hls-live-streams-loop-forever/43942/1 "2016-08-08T16:08:03Z")

</div>

Wowza Streaming Engine 4.5.0

Inside of a live stream application module, I’m doing this:

```auto
Stream stream = Stream.createInstance(thisInstance,"video");
stream.play(fileName,0,-1,false);	

```

This will start streaming a video to the “video” channel of my application.

However, this stream does not stop at the end of the video. It just loops over again at the beginning, despite that “false” there at the end, which should be telling it not to repeat.

Is there any way I can get this stream to automatically close at the end of the video? Right now I’m doing a workaround where I’m sending the “duration” as a query parameter, and then using that as a timer to close the stream, but this isn’t very accurate, currently.

The logs say:

```auto
INFO stream play video -
...
INFO server comment - onPlaylistItemStop: video
INFO server comment - Stream.switch[live/_definst_/video]: index: 0 name:small.mp4 start:0 length:-1
INFO server comment - onPlaylistItemStart: video
...
INFO server comment - onPlaylistItemStop: video
INFO server comment - Stream.switch[live/_definst_/video]: index: 0 name:small.mp4 start:0 length:-1
INFO server comment - onPlaylistItemStart: video
...

```

---

<div class="post-metadata">

### Author: ![Jim\_Houseman](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@Jim\_Houseman](https://community.wowza.com/u/Jim_Houseman)
#### Post date: [August 9, 2016, 8:31am UTC](https://community.wowza.com/t/hls-live-streams-loop-forever/43942/2 "2016-08-09T08:31:05Z")

</div>

Apparently, I’m misunderstanding how stream.play() works. The [documentation](https://www.wowza.com/resources/serverapi/4.5.0/com/wowza/wms/stream/publish/Stream.html#play%28java.lang.String,)says that this only adds an item to the playlist. I still have to control the playlist through other means.

Calling stream.close() on IStreamActionNotify onPlaylistItemStop works
