Question

Flutter vimeo player can't working (Config URL not working)

We have used the vimeo_video_player package for some time in our app. Recently more and more Vimeo videos have stopped working. We updated to the latest version of the package, but still this error.

I have noticed in my debugging that, the config API is not working for all the videos as earlier. Public video links are working but not private.

enter image description here

Any suggestions for alternate solutions?

I have tried loading without using the config URL but have not gotten the desired result.

 3  46  3
1 Jan 1970

Solution

 0

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;
    }
  }```
2024-07-23
Sanjay Kapdiya