Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to read m3u8 file from AWS Cloudfront (using AWS Signed URL technology) #57

Open
vanderke opened this issue Mar 8, 2024 · 4 comments

Comments

@vanderke
Copy link

vanderke commented Mar 8, 2024

I've got several audio and video files in an S3 bucket serviced by Cloudfront. I'm sure that the .m3u8 files are valid, as I can get access to them if I use a signed url. However, I can't seem to get the headers to get passed in the subsequent calls. Here's the code snippet that I'm using (taken string from the initState() method in the sample code):

    String url = "https://cdn.example.com/folder1/folder2/folder3/myMovie.m3u8";
    Map<String, String> httpHeaders = {
      "useCookies": "true",
      "CloudFront-Policy": "${AWSCloudFrontSignedUrl.cloudFrontPolicy}",
      "CloudFront-Signature": "${AWSCloudFrontSignedUrl.cloudFrontSignature}",
      "CloudFront-Key-Pair-Id": "${AWSCloudFrontSignedUrl.cloudFrontKeyPairId}",
    };
    _controller = VideoPlayerController.networkUrl(Uri.parse(url), httpHeaders: httpHeaders)
      ..initialize().then((_) {
        // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
        setState(() {});
      });

When the player is trying to intialize, I see that some of the URLs have the correct URL on them, but some do not.
image
This is done in the same network call, but without all of the signature stuff added to it:
image
I'm not sure how to get the player to add the extra parameters to each and every item that is in the playlist. Thanks for your help!

@vanderke
Copy link
Author

There does seem to be a way to do this transparently using this article from AWS and having 2 different cloudfronts going on. So I don't think that this is going to stop me from using this, however, there still seems to be an issue with using the cookies passed in through the header consistently.

@aviettran
Copy link

Did you ever find a satisfactory resolution to this?

Adam

@vanderke
Copy link
Author

Hey Adam,
Unfortunately, no. The article from AWS that I linked to was more "sample code" rather than fully tested code, and as a result, it didn't work as advertised. We're still working through the AWS configuration to see if we can get it to work, but so far, it's still not working.

@aviettran
Copy link

Okay. If your organization wants to write me up an hourly contract, I'd love to take a look. This type of thing genuinely interests me so I'm willing to tackle it if you need help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants