Wowza Community

How to play a Stream file using the Java APIs?

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))
	IApplicationInstance appInstance = vhost.getApplicationInstance("mkktest", "_definst_");
	 Stream	stream = Stream.createInstance(appInstance, "myStream");
	 stream.addToPlaylist(0, "", 0, 100);
	 // stream.addToPlaylist(1, "m3u8:", 0, 100);;

	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();
	} catch (Exception e) {
		WMSLoggerFactory.getLogger(null).error("HttpTest: " + e.toString());



My file is:

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: 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 - : java.lang.NullPointerException|at|at|at java.base/ Source)|

How do I solve this?

@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:”, 0, 100);;

Only the stream name can be added to a playlist:,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]/content (your stream file that you’re connecting to)