2

I am trying to play a secured video from CloudFront with @react-native-community/react-native-video.

To reproduce the video I have to set 3 cookies: CloudFront-Key-Pair-Id, CloudFront-Policy and CloudFront-Signature.

I've been able to reproduce the video in IOS with this module: react-native-cookies

But I am not being able to reproduce the video in android. How can I set the cookies to play this video?

The video is a .m3u8 extension (HLS)

Thank you very much!

1 Answers1

5

I solved it.

Finally, to be able to reproduce it on Android I did the following on the Video component:

enter image description here

For IOS I just set the cookies with the react-native-cookie-store library:

CookieManager.set({
          name:'CloudFront-Key-Pair-Id',
          value: 'Your pair ID',
          domain: 'Your domain',
          path: '/',
          origin: 'Your origin (I used same as domain)',
          version: '1',
          expiration: '2099-05-30T12:30:00.00-05:00',
        });

Called this methods 3 times, for CloudFront-Key-Pair-Id, CloudFront-Policy and CloudFront-Signature.

Hope this helps!

  • Thanks for the solution. What do I put for the domain when setting a cookie for iOS it gives me NSUrlErrorDomain? Cloudfront domain? – user2657198 Feb 06 '20 at 01:40
  • Thanks mate, perfect solution. I'll paste this link for some issues in `react-native-video` repo. Cheers! – f4z3k4s Feb 25 '21 at 10:38
  • This solution is not working for me. Here is my question https://stackoverflow.com/questions/74680861/react-native-video-how-to-send-cloudfront-signed-cookies – Faisal Shaikh Dec 04 '22 at 21:27