H
H
Harconnen2020-06-11 17:06:57
React
Harconnen, 2020-06-11 17:06:57

How to run the next track in React in video.js?

Hello, I created a player on React, everything works, but it turned out to be compatible with the video.js player.
I mount the player in componentDidMount()

this.player = videojs(this.videoNode, this.state.videoJsOptions);

I give all the necessary data, everything works.
videoJsOptions: {
                sources: [
                    {
                    src: 'URL',
                    type: ''MIME,
                    },
                ],
            }

On the "Next" button, I change this.state.videoJsOptions to new values ​​​​(with a regular player, this was enough to play the next track)
But video.js still plays the track that was the first.
Tell me, maybe after changing this.state.videoJsOptions - you need to somehow overload the player so that it starts playing a new track.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Harconnen, 2020-06-11
@Harconnen

It seems that I figured it out myself, if anyone encounters the same, here is the solution:

player.src({
  src: 'http://......',
  type: 'video/mp4'
});

It is necessary to pass both the address and necessarily the type, video.js cannot auto-detect, if the type is not passed, it will not work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question