# How to play a Stream file using the Java APIs?

**URL:** <https://community.wowza.com/t/how-to-play-a-stream-file-using-the-java-apis/95932>\
**Category:** Wowza Streaming Engine\
**Tags:** wowza-streaming-server-java-api\
**Created:** [February 23, 2023, 3:35pm UTC](https://community.wowza.com/t/how-to-play-a-stream-file-using-the-java-apis/95932 "2023-02-23T15:35:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![khat33b](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@khat33b](https://community.wowza.com/u/khat33b)\
**Post date:** [February 23, 2023, 3:35pm UTC](https://community.wowza.com/t/how-to-play-a-stream-file-using-the-java-apis/95932/1 "2023-02-23T15:35:17Z")

</div>

I am trying to play a m3u8 file when an HTTP provider is called. I tried putting it directly and putting it in a stream file but both ways are not working. How do I do this?

This is my code:

public class HttpTest extends HTTProvider2Base {

```
public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
	if (!doHTTPAuthentication(vhost, req, resp))
		return;
	
	IApplicationInstance appInstance = vhost.getApplicationInstance("mkktest", "_definst_");
	 Stream	stream = Stream.createInstance(appInstance, "myStream");
	 stream.addToPlaylist(0, "bipbop.stream", 0, 100);
	 // stream.addToPlaylist(1, "m3u8:https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8", 0, 100);
	 stream.play(0);

	String helloStr = stream.toString();
	String retStr = "<html><head><title>" + helloStr + "</title></head><body>" + helloStr + "</body></html>";

	try {
		OutputStream out = resp.getOutputStream();
		byte[] outBytes = retStr.getBytes();
		out.write(outBytes);
	} catch (Exception e) {
		WMSLoggerFactory.getLogger(null).error("HttpTest: " + e.toString());
	}

}

```

}

My bipbop.stream file is:

`https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8`

With putting the stream file, I get the error:

` Container failed: java.lang.Exception: QTUtils.parseQTMediaContainer: File is missing 'moov' atom.`

With putting the m3u8 directly, I get the error:

```
INFO server comment - Stream.switch[mkktest/_definst_/myStream]: index: 0 name:m3u8:https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8 start:0 length:100 interItemGap(a/v/c/u):0/0/0/0
ERROR server comment - MediaReaderFactory.getInstance: Missing definition for m3u8
ERROR server comment - PublishingProviderMediaReader.play : java.lang.NullPointerException|at com.wowza.wms.stream.publish.PublishingProviderMediaReader.play(PublishingProviderMediaReader.java:474)|at com.wowza.wms.stream.publish.Stream.run(Stream.java:226)|at java.base/java.lang.Thread.run(Unknown Source)|

```

How do I solve this?

---

<div class="post-metadata">

**Author:** ![Jason\_Tuchler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/jason_tuchler/32/462_2.png) [@Jason\_Tuchler](https://community.wowza.com/u/Jason_Tuchler)\
**Post date:** [February 27, 2023, 9:27pm UTC](https://community.wowza.com/t/how-to-play-a-stream-file-using-the-java-apis/95932/2 "2023-02-27T21:27:29Z")

</div>

@khat33b I see in your logging it’s still referencing the stream name as the M3U8 url, as you did comment out this in your code:  
// stream.addToPlaylist(1, “m3u8:[https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop\_4x3/bipbop\_4x3\_variant.m3u8](https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8)”, 0, 100);  
stream.play(0);

Only the stream name can be added to a playlist:  
[https://www.wowza.com/resources/serverapi/com/wowza/wms/stream/publish/Playlist.html#addItem(java.lang.String,int,int)](https://www.wowza.com/resources/serverapi/com/wowza/wms/stream/publish/Playlist.html#addItem(java.lang.String,int,int))

Missing a moov atom is usually an error with MP4 content that does that was not closed properly when created.

I would recommend testing with another source, if having further issues, reach out to Wowza support with full workflow details and the below support info:  
[install-dir]/conf  
[install-dir]/logs  
[install-dir]/content (your stream file that you’re connecting to)

> **[Open a Support Ticket](https://www.wowza.com/support/open-ticket)**
>
> Open a Wowza suppor ticket so our technical support engineers worldwide can help you succeed with your Wowza software and services.
