最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Vimeo API suddenly stopped returning progressive field in video response - Issue with Flutter Android app integration - Stack Ov

programmeradmin1浏览0评论

I have integrated Vimeo video API into my Flutter Android app, and it was working fine until recently. I was calling the following Vimeo API endpoint:

GET /{video_id}?fields=play,name,pictures

The response I used to get included a "progressive" field under the "play" field, as shown in the documentation:

Here’s the expected sample response from the API:

{
  "play": {
    "progressive": [
      {
        "type": "video/mp4",
        "codec": "H264",
        "width": 480,
        "height": 360,
        "link": "/.../video.mp4",
        "created_time": "2018-08-27T14:58:07+00:00",
        "size": 1067683,
        "fps": 29.97
      },
      {
        "type": "video/mp4",
        "codec": "H264",
        "width": 720,
        "height": 540,
        "link": "/.../video.mp4",
        "created_time": "2018-08-27T14:58:07+00:00",
        "size": 2876666,
        "fps": 29.97
      }
    ]
  }
}

However, recently, the API response has changed, and I am only receiving this:

{
  "play": {
    "status": "playable"
  }
}

This is causing my app to break, as the progressive field is no longer included. I haven’t made any changes to my code or the API call in my Flutter app, but the integration has suddenly stopped working.

I am using a Vimeo Plus membership.

I have tried checking this using Postman. here is my flutter code for refreance:

class VimeoManager {
  static final VimeoManager _instance = VimeoManager._internal();
  static VimeoManager get instance => _instance;
  final String accessToken;

  VimeoManager._internal() : accessToken = const String.fromEnvironment('VIMEO_ACCESS_TOKEN');

  Future<VimeoVideoInfo> fetchVimeoVideoData(String videoId) async {
    final apiUrl = Uri.parse('/$videoId?fields=play,name,pictures');
    final response = await http.get(apiUrl, headers: {
      AUTHORIZATION: 'Bearer $accessToken',
    });

    if (response.statusCode != 200) {
      Logger().e('Failed to load video data');
      throw Exception('Failed to load video data');
    }

    final Map<String, dynamic> json = jsonDecode(response.body);

    // Use the VimeoVideo model to parse the JSON response
    final vimeoVideo = VimeoVideo.fromJson(json);

    final thumbnailURLs = <VimeoThumbnailQuality, Uri>{};
    final videoURLs = <VimeoVideoQuality, Uri>{};

    // Extract video URLs
    final play = vimeoVideo.play;
    if (play != null) {
      final progressive = play.progressive;
      if (progressive != null) {
        for (final video in progressive) {
          final qualityString = video.rendition;
          final quality = qualityString?.toVimeoVideoQuality() ?? VimeoVideoQuality.unknown;
          final urlStr = video.link;
          if (quality != VimeoVideoQuality.unknown && urlStr != null) {
            videoURLs[quality] = Uri.parse(urlStr);
          }
        }
      }
    }

    // Extract thumbnail URLs
    final pictures = vimeoVideo.pictures;
    if (pictures != null) {
      final sizes = pictures.sizes;
      if (sizes != null) {
        for (final size in sizes) {
          final qualityString = '${size.width}x${size.height}';
          final quality = qualityString.toVimeoThumbnailQuality();
          if (quality != VimeoThumbnailQuality.qualityUnknown && size.link != null) {
            thumbnailURLs[quality] = Uri.parse(size.link!);
          }
        }
      }
    }

    // Extract video title
    final name = vimeoVideo.name;
    if (name == null) {
      throw Exception('Invalid JSON format from Vimeo');
    }

    return VimeoVideoInfo(
      title: name,
      thumbnailURL: thumbnailURLs,
      videoURL: videoURLs,
    );
  }
}

I’m wondering if this is an issue from Vimeo’s side or if there is something I missed in my API request. Can someone help me understand why the progressive field is missing from the response, and how to handle this issue?

I have integrated Vimeo video API into my Flutter Android app, and it was working fine until recently. I was calling the following Vimeo API endpoint:

GET https://api.vimeo/videos/{video_id}?fields=play,name,pictures

The response I used to get included a "progressive" field under the "play" field, as shown in the documentation: https://developer.vimeo/api/files/video-links

Here’s the expected sample response from the API:

{
  "play": {
    "progressive": [
      {
        "type": "video/mp4",
        "codec": "H264",
        "width": 480,
        "height": 360,
        "link": "https://player.vimeo/progressive_redirect/playback/.../video.mp4",
        "created_time": "2018-08-27T14:58:07+00:00",
        "size": 1067683,
        "fps": 29.97
      },
      {
        "type": "video/mp4",
        "codec": "H264",
        "width": 720,
        "height": 540,
        "link": "https://player.vimeo/progressive_redirect/playback/.../video.mp4",
        "created_time": "2018-08-27T14:58:07+00:00",
        "size": 2876666,
        "fps": 29.97
      }
    ]
  }
}

However, recently, the API response has changed, and I am only receiving this:

{
  "play": {
    "status": "playable"
  }
}

This is causing my app to break, as the progressive field is no longer included. I haven’t made any changes to my code or the API call in my Flutter app, but the integration has suddenly stopped working.

I am using a Vimeo Plus membership.

I have tried checking this using Postman. here is my flutter code for refreance:

class VimeoManager {
  static final VimeoManager _instance = VimeoManager._internal();
  static VimeoManager get instance => _instance;
  final String accessToken;

  VimeoManager._internal() : accessToken = const String.fromEnvironment('VIMEO_ACCESS_TOKEN');

  Future<VimeoVideoInfo> fetchVimeoVideoData(String videoId) async {
    final apiUrl = Uri.parse('https://api.vimeo/videos/$videoId?fields=play,name,pictures');
    final response = await http.get(apiUrl, headers: {
      AUTHORIZATION: 'Bearer $accessToken',
    });

    if (response.statusCode != 200) {
      Logger().e('Failed to load video data');
      throw Exception('Failed to load video data');
    }

    final Map<String, dynamic> json = jsonDecode(response.body);

    // Use the VimeoVideo model to parse the JSON response
    final vimeoVideo = VimeoVideo.fromJson(json);

    final thumbnailURLs = <VimeoThumbnailQuality, Uri>{};
    final videoURLs = <VimeoVideoQuality, Uri>{};

    // Extract video URLs
    final play = vimeoVideo.play;
    if (play != null) {
      final progressive = play.progressive;
      if (progressive != null) {
        for (final video in progressive) {
          final qualityString = video.rendition;
          final quality = qualityString?.toVimeoVideoQuality() ?? VimeoVideoQuality.unknown;
          final urlStr = video.link;
          if (quality != VimeoVideoQuality.unknown && urlStr != null) {
            videoURLs[quality] = Uri.parse(urlStr);
          }
        }
      }
    }

    // Extract thumbnail URLs
    final pictures = vimeoVideo.pictures;
    if (pictures != null) {
      final sizes = pictures.sizes;
      if (sizes != null) {
        for (final size in sizes) {
          final qualityString = '${size.width}x${size.height}';
          final quality = qualityString.toVimeoThumbnailQuality();
          if (quality != VimeoThumbnailQuality.qualityUnknown && size.link != null) {
            thumbnailURLs[quality] = Uri.parse(size.link!);
          }
        }
      }
    }

    // Extract video title
    final name = vimeoVideo.name;
    if (name == null) {
      throw Exception('Invalid JSON format from Vimeo');
    }

    return VimeoVideoInfo(
      title: name,
      thumbnailURL: thumbnailURLs,
      videoURL: videoURLs,
    );
  }
}

I’m wondering if this is an issue from Vimeo’s side or if there is something I missed in my API request. Can someone help me understand why the progressive field is missing from the response, and how to handle this issue?

Share Improve this question edited Feb 14 at 4:30 PARANJAY asked Feb 11 at 6:48 PARANJAYPARANJAY 971 gold badge1 silver badge11 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

the Vimeo account must be on a free plan or a plus plan(legacy), which doesn't have access to Vimeo video files. As stated in documentation, accessing video files via the API requires a Standard (or higher) plan, or the legacy Pro plan (or higher).

I had issues with getting reliable progressive data from: https://api.vimeo/videos/

I was forced to migrate to Vimeo api v2 which requires a bearer token.

This is see a snip from my code:

  static Future<List<VimeoInfo>> getVideoData(String vimeoId) async {
    try {
      final http.Response response = await http.get(
          Uri.parse("http://vimeo/api/v2/video/$vimeoId.json"),
          headers: {
            "Accept": "application/json",
            "Authorization": "Bearer MySecretToken-xxxxxx"
          });

      print(jsonDecode(response.body));

      return response.statusCode == 200
          ? vimeoInfoFromJson(jsonDecode(response.body))
          : [];
    } catch (e) {
      debugPrint(e.toString());
      return [];
    }
  }

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论