fromM3u static method
Asynchronously loads an M3U/M3U8 playlist from a local file path or remote HTTP/HTTPS URL and expands it into a List<AudioSource>.
Implementation
static Future<List<AudioSource>> fromM3u(String pathOrUrl) async {
final isUrl =
pathOrUrl.startsWith('http://') || pathOrUrl.startsWith('https://');
if (isUrl) {
final response = await http.get(Uri.parse(pathOrUrl));
if (response.statusCode == 200) {
return fromM3uContent(response.body);
} else {
throw Exception(
'Failed to fetch M3U playlist from network (Status ${response.statusCode})',
);
}
} else {
final file = File(pathOrUrl);
if (!await file.exists()) {
throw FileSystemException('M3U playlist file not found', pathOrUrl);
}
final content = await file.readAsString();
return fromM3uContent(content, baseDirectory: file.parent.path);
}
}