react-nativevideocookiesreact-native-videoreact-native-cookies

React Native Video Cookies


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!


Solution

  • 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!