apivideo / api.video-react-player

api.video React player component
MIT License
22 stars 0 forks source link

Private video session management not working #9

Closed Tommo56700 closed 1 year ago

Tommo56700 commented 1 year ago

I’m experiencing an issue using the react-player with private video. Following this article I was under the impression that the api-video react-player would handle the X-Token-Session automatically. However, in practice, this does not seem to work in a react SPA

const PlayerView: FC<IPlayerViewProps> = ({ video }) => {
 const videoRef = useRef<ApiVideoPlayer>(null)

 const { videoId } = video

 const token = video.assets?.player?.split('=')[1]

return (
     <ApiVideoPlayer
        video={video._public ? { id: videoId } : { id: videoId, token: token }}
        videoStyleObjectFit={'cover'}
        ref={videoRef}
        style={{
            width: 'auto',
            height: 300,
            borderRadius: 4,
            overflow: 'hidden',
        }}
     />
 )
{

I am writing an app that opens a popup where the video can be played from. The first time I open the pop-up the video will plays fine, but if the popup is closed and re-opened the video is not available. Surely, I should not have to make a request for a new token each time? Perhaps I am doing something wrong with managing state? Are there any working samples of the react-player with private video?

olivierapivideo commented 1 year ago

Hi @Tommo56700 ,

We've just made a change in our player that should fix your issue. Can you confirm?

olivierapivideo commented 1 year ago

Don't hesitate to reopen if it's not solved.