TheWidlarzGroup / react-native-video

A <Video /> component for react-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG]: _videoRef$current.setNativeProps is not a function (it is undefined)

amitmehtacode opened this issue · comments

Version

6.1.2

What platforms are you having the problem on?

No response

Architecture

Old architecture

What happened?

A bug occurred!

To dynamically change the token, I use the following code:

videoRef.current?.setNativeProps({
      source: {
        uri: uri,
        type: 'm3u8',
        headers: {
          Authorization: `Bearer ${token}`,
        },
      },
    });

The above code works well in version 5.2.1.

Reproduction

repository link

Reproduction

Step to reproduce this bug are:

open the app
run the video player

setNativeProps is deprecated, you should save source in state - if you want to update source via ref you will need to create your own component with forwardRef that will handle update of source state

setNativeProps is deprecated, you should save source in state - if you want to update source via ref you will need to create your own component with forwardRef that will handle update of source state

@KrzysztofMoch After making these changes, the progress value goes back by 15 seconds with each token change.

@KrzysztofMoch
In the previous version, I managed to change the token like this, and it worked fine without affecting the progress value:

videoRef.current?.setNativeProps({
      source: {
        uri: uri,
        type: 'm3u8',
        headers: {
          Authorization: `Bearer ${token}`,
        },
      },
    });

Hello @amitmehtacode, I am a bit surprised, because header is not parsed in source 🤔
There is only a field "requestHeaders" in source which is not documented :/

Hello @amitmehtacode, I am a bit surprised, because header is not parsed in source 🤔 There is only a field "requestHeaders" in source which is not documented :/

But If I remove the headers:{} then the video is not playable.

Hello @amitmehtacode, I am a bit surprised, because header is not parsed in source 🤔 There is only a field "requestHeaders" in source which is not documented :/

I also put requestHeaders but still the video is not playable 🙁

@freeboub Any update for the same.