Can I get an example of how to download media using HLS?
When I run this code, I receive code=200 response almost immediately, but the data is null.
After my code finishes running, I see the download continuing in the "View HTTP Traffic" window.
What is the correct way to download this type of media?
import Toybox.Communications;
import Toybox.Lang;
import Toybox.System;
import Toybox.Media;
import Toybox.Time;
import Toybox.Application;
class AbooksSyncDelegate extends Communications.SyncDelegate {
function initialize() {
SyncDelegate.initialize();
}
function onStartSync() {
var url =
"https"+"://"+"r1.akniga.club/b/105490/pl.m3u8?res=c6scbgODufz669hNdqRyPA&expires=1765497600";
var options = {
:method => Communications.HTTP_REQUEST_METHOD_GET,
:headers => {
"Content-Type" => Communications.REQUEST_CONTENT_TYPE_URL_ENCODED,
},
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_HLS_DOWNLOAD,
:mediaEncoding => Media.ENCODING_M4A,
};
Communications.makeWebRequest(
url,
{},
options,
self.method(:onWebResponse)
);
}
function onWebResponse(code, data) {
System.println("code: " + code);
System.println("data: " + data);
}
function isSyncNeeded() as Boolean {
return true;
}
function onStopSync() as Void {
Communications.cancelAllRequests();
Communications.notifySyncComplete(null);
}
}
result:
code: 200
data: null