newtaDev / pod_player

Video player for flutter web & mobile devices, Play video from youtube or vimeo or network in flutter using pod player
https://pub.dev/packages/pod_player
MIT License
96 stars 162 forks source link

Vimeo videos not working: Missing "progressive" #182

Open greatschism opened 2 months ago

greatschism commented 2 months ago

===== VIMEO API ERROR: type 'Null' is not a subtype of type 'List<dynamic>' in type cast ==========

I am not sure what the problem is here, but it stopped at 130pm yesterday suddenly.

Danzzel commented 2 months ago

Yeah, all video are broken

AhsanFarooq0017 commented 2 months ago

===== VIMEO API ERROR: type 'Null' is not a subtype of type 'List<dynamic>' in type cast ==========

I am not sure what the problem is here, but it starts suddenly.

Hey did you find any solution?

greatschism commented 2 months ago

The code below works in a tester app. But when I try to run it in my main app, it starts playing and then crashes. I contacted Vimeo support regarding the issue, but they haven't been very helpful. The problem seems to be that the progressive key and data are missing and only HLS and DASH are available. I don't know how to repackage it either.


    String videoId,
    String? hash,
  ) async {
    try {
      final response = await _makeRequestHash(videoId, hash);
      var jsonData = <dynamic>[];
      var progressiveUrls = <VideoQalityUrls>[];
      // print(response.body);
      // print the key value pair of the response
      // is jsonDecode(response.body is a map or a list or something else
      // if it is a map, then proceed, else fail

      if (jsonDecode(response.body) is Map) {
        print("response.body is a map");
      } else {
        print("response.body is not a map");
      }

      if (jsonDecode(response.body)['request']['files']['progressive'] != null) {
        jsonData = jsonDecode(response.body)['request']['files']['progressive'] as List<dynamic>;
        print(jsonData);
        progressiveUrls = List.generate(
          jsonData.length,
          (index) => VideoQalityUrls(
            quality: int.parse(
              (jsonData[index]['quality'] as String?)?.split('p').first ?? '0',
            ),
            url: jsonData[index]['url'] as String,
          ),
        );
      }
      if (progressiveUrls.isEmpty && jsonDecode(response.body)['request']['files']['hls'] != null) {
        final jsonRes = jsonDecode(response.body)['request']['files']['hls']['cdns'];

        for (final element in (jsonRes as Map).entries.toList()) {
          progressiveUrls.add(
            VideoQalityUrls(
              quality: 720,
              url: element.value['url'] as String,
            ),
          );
          break;
        }
      }

      if (progressiveUrls.isEmpty && jsonDecode(response.body)['request']['files']['dash'] != null) {
        jsonData = jsonDecode(response.body)['request']['files']['dash']['cdns'] as List<dynamic>;

        progressiveUrls = List.generate(
          jsonData.length,
          (index) => VideoQalityUrls(
            quality: int.parse(
              (jsonData[index]['quality'] as String?)?.split('p').first ?? '0',
            ),
            url: jsonData[index]['url'] as String,
          ),
        );
      }
      return progressiveUrls;
    } catch (error) {
      if (error.toString().contains('XMLHttpRequest')) {
        log(
          podErrorString(
            '(INFO) To play vimeo video in WEB, Please enable CORS in your browser',
          ),
        );
      }
      debugPrint('===== 1VIMEO API ERROR: $error ==========');
      rethrow;
    }
  }```
greatschism commented 2 months ago

response from Vimeo:

Hello,

Thank you for your inquiry. I can see you are using the player/config URL https://player.vimeo.com/video/{video_id}/config to retrieve the Video's metadata.

The player/config URL is not the correct way to retrieve a video's Metadata or Video links. This was an unpublished url and was only designed for the player's internal backend and was never published for public use. This internal player URL is also no longer being maintained and has been deprecated I believe for at least the last 2-3 years.

Instead, you should use the videos API endpoint as shown in our documentation. This will return a Videos complete metadata information. Please see https://developer.vimeo.com/api/reference/videos#get_video on how to use the endpoint along with https://developer.vimeo.com/api/reference/response/video which will show you all available responses and definitions. Thank you,

newtaDev commented 2 months ago

response from Vimeo:

Hello,

Thank you for your inquiry. I can see you are using the player/config URL https://player.vimeo.com/video/{video_id}/config to retrieve the Video's metadata.

The player/config URL is not the correct way to retrieve a video's Metadata or Video links. This was an unpublished url and was only designed for the player's internal backend and was never published for public use. This internal player URL is also no longer being maintained and has been deprecated I believe for at least the last 2-3 years.

Instead, you should use the videos API endpoint as shown in our documentation. This will return a Videos complete metadata information. Please see https://developer.vimeo.com/api/reference/videos#get_video on how to use the endpoint along with https://developer.vimeo.com/api/reference/response/video which will show you all available responses and definitions. Thank you,

Hey, Thanks for reaching out to Vimeo and finding a solution, But for some reason, the API they provided here is not working as expected could you please check with them and get back?

The API they mentioned: (https://developer.vimeo.com/api/reference/videos#get_video )

GET Request: https://api.vimeo.com/videos/518228118

Response:

{
    "error": "Something strange occurred. Please get in touch with the app's creator.",
    "link": null,
    "developer_message": "The app didn't receive the user's credentials.",
    "error_code": 8003
}
chatali96 commented 2 months ago

Let us know when the VIMEO API ERROR gets resolved.

mateusfmfm commented 2 months ago

Thx guys, I had the same problem

newtaDev commented 2 months ago

fixed this issue in pod_player: ^0.2.2 please check and let me know

AhsanFarooq0017 commented 2 months ago

fixed this issue in pod_player: ^0.2.2 please check and let me know

I can not update the dependency because my app is old can you tell me any work around?

edwardnagy commented 2 months ago

@AhsanFarooq0017 You could clone the compatible version and apply the fix locally.

Danzzel commented 2 months ago

fixed this issue in pod_player: ^0.2.2 please check and let me know

I needed to upgrade a lot of packages but now it works fine. Thx a lot

AhsanFarooq0017 commented 2 months ago

@AhsanFarooq0017 You could clone the compatible version and apply the fix locally.

can you please share the complete solution?

aaronm67 commented 2 months ago

Please do not use the /config URL here, this is an internal API that changes without notice, so this library will break again in the future, and access to this URL will likely be disallowed in the future. Vimeo has a REST API that should be used, and has all of the data you need https://developer.vimeo.com/api/guides/start

HasithaAcc commented 2 months ago

I have updated the plugin with out an error but after updating to 0.2.2 video sound is not coming

this happens when we use vemio id with the hash

greatschism commented 2 months ago

Please do not use the /config URL here, this is an internal API that changes without notice, so this library will break again in the future, and access to this URL will likely be disallowed in the future. Vimeo has a REST API that should be used, and has all of the data you need https://developer.vimeo.com/api/guides/start

How do you return a player that does not need auth and does not expire?

aaronm67 commented 2 months ago

How do you return a player that does not need auth and does not expire?

You don't, this is intentional. You should use the REST API to get video links, which requires registering an app on https://developer.vimeo.com.

Your users can register an app on https://developer.vimeo.com and configure this player with their access token. There are many different access tokens you can use, you can generate a "public" access key that doesn't have write permission, but we still require authentication for rate limiting purposes. Details of different types of access tokens are available here: https://developer.vimeo.com/api/guides/start#generate-access-token

If you don't wish to use the REST API, there is an OEmbed API that doesn't require authentication, https://developer.vimeo.com/api/oembed. This is only available for the Vimeo Player, not direct video links, so you'd need to embed an iFrame to support this.

Fully anonymous access to direct video files is not supported. The config URL you're currently using is an internal API that will change without notice, and will not be permanently available.

robertjones26 commented 2 months ago

I cam across this and had to add the header with token. I searched for a couple of days and I think something changed on Vimeos side.

header = { 'Authorization': 'bearer {token}', 'Accept': 'application/vnd.vimeo.*+json;version=3.4', };

AAber commented 1 month ago

I had this issue with the /config API and once I moved to the official token API the progressive issue was resolved. If your app presents videos from multiple Vimeo accounts you will need to connect the Vimeo accounts or use multiple tokens. If you can't connect the Vimeo accounts make sure your app has a matching token for each Vimeo account you use.

panalgin commented 1 week ago

It seems like we are no longer be able to retrieve video file links without a Pro Plan on Vimeo, with their official REST API

image

hgndgn commented 4 days ago

I had this issue with the /config API and once I moved to the official token API the progressive issue was resolved. If your app presents videos from multiple Vimeo accounts you will need to connect the Vimeo accounts or use multiple tokens. If you can't connect the Vimeo accounts make sure your app has a matching token for each Vimeo account you use.

How are you playing the videos?

AAber commented 4 days ago

I'm using https://pub.dev/packages/pod_player in my Flutter app.

hgndgn commented 4 days ago

I'm using https://pub.dev/packages/pod_player in my Flutter app.

@AAber Yeah me too, but playing the video using the id and the hash does not work anymore, therefore I asked. I couldn't find any API-endpoint, where I can pass the hash of the video.

AAber commented 4 days ago

Use this snip to play the URL you get from the API:

  void initState() {
    controller = PodPlayerController(
        playVideoFrom: PlayVideoFrom.vimeo(widget.vimeoID),
        podPlayerConfig: PodPlayerConfig(
            videoQualityPriority: [360, 720, 1080], forcedVideoFocus: true))
      ..initialise();
    if (widget.videoUrls != null) {
      if (widget.videoUrls!.length != 0) {
        print('init controller');
        controller = PodPlayerController(
            playVideoFrom: PlayVideoFrom.networkQualityUrls(
              videoUrls: widget.videoUrls!,
            ),
            podPlayerConfig: PodPlayerConfig(
                videoQualityPriority: [360, 720, 1080], forcedVideoFocus: true))
          ..initialise();
      }
      super.initState();
    }
  }