Updated two methods of the pod player
static Future<Response> _makeRequestHash(String videoId, String? hash) {
return http.get(
Uri.parse("https://api.vimeo.com/videos/$videoId?fields=play"),
headers: {"Authorization": "Bearer {**ADD YOUR PERSONAL ACCESS TOKEN HERE**}",
"Content-Type": "application/json"});
}
static Future<List<VideoQalityUrls>?> getVimeoVideoQualityUrls(String videoId,
String? hash,) async {
try {
final response = await _makeRequestHash(videoId, hash);
final jsonData = jsonDecode(response.body)['play'];
final dashData = jsonData['dash'];
final hlsData = jsonData['hls'];
final List<dynamic> rawStreamUrls =
(jsonData['progressive'] as List<dynamic>?) ?? <dynamic>[];
final List<VideoQalityUrls> vimeoQualityUrls = [];
for (final item in rawStreamUrls) {
vimeoQualityUrls.add(
VideoQalityUrls(
quality: (item['height'] as int) ?? 0,
url: item['link'] as String,
),
);
}
if (vimeoQualityUrls.isEmpty) {
vimeoQualityUrls.add(
VideoQalityUrls(
quality: 720,
url: "",
),
);
}
return vimeoQualityUrls;
} catch (error) {
if (error.toString().contains('XMLHttpRequest')) {
log(
podErrorString(
'(INFO) To play vimeo video in WEB, Please enable CORS in your browser',
),
);
}
debugPrint('===== VIMEO API ERROR: $error ==========');
rethrow;
}
}```