getQuality method
Retrieves a thumbnail image for the provided media URL.
This asynchronous function calls _controller.getThumbnail
with an optional url
parameter and returns a Uint8List
containing the image data.
Get Qualitie for any specific url without playing
This asynchronous function calls _controller.getQuality
with an optional url
parameter and returns a List of String
Implementation
// Future<Uint8List> getThumbnail({String? url}) async {
// return await _controller.getThumbnail(url: url);
// }
/// Get Qualitie for any specific url without playing
///
/// This asynchronous function calls `_controller.getQuality`
/// with an optional `url` parameter and returns a List of String
Future<List<String>> getQuality(String url) async {
List<String> qualities = [];
try {
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
final body = response.body;
// Extract qualities using regex
final regex = RegExp(
r'#EXT-X-STREAM-INF:[^\n]*BANDWIDTH=(\d+)[^\n]*RESOLUTION=(\d+x\d+)',
multiLine: true);
final matches = regex.allMatches(body);
for (var match in matches) {
String resolution = match.group(2) ?? "Unknown";
qualities.add(resolution);
}
}
} catch (e) {
throw Exception(e);
}
return qualities;
}