vimeo / player.js

Interact with and control an embedded Vimeo Player.
https://player.vimeo.com/api/demo
MIT License
1.43k stars 263 forks source link

`player.loadVideo()` sometimes freezes the video playback #1024

Open obber opened 2 months ago

obber commented 2 months ago

Expected Behavior

I expect player.loadVideo(ID) to play ID without issue once it's loaded.

Actual Behavior

Video ID will begin playing but freeze in the middle of playback.

Steps to Reproduce

I've recorded a loom of me reproducing this with a bit more context here: https://www.loom.com/share/e13b15c651d549e884d7c41db83c305f

  1. Clone this minimal reproduction repository: https://github.com/obber/vimeo-playback-issue-sandbox
  2. CD to the root directory of the repo.
  3. Run npm i
  4. Run npm start
  5. Navigate videos using the forwards / back button (in no particular pattern, at least that I've observed)
  6. Observe that the video will freeze sometimes for some videos.

Thanks for investigating! Any direction or guidance would be really appreciated :)

KevinWilson-Linney commented 2 months ago

I am experiencing the same issue.

We have a set of 5 videos. Intermittently, one of the videos will load and not start streaming any data.

Edit:

The issue with .loadVideo() seems to be related to the background & autoplay options. If you leave the controls visible, you will see the video loads ahead but does not play.

A crude fix to this for the time being:

player
    .loadVideo({video_options})
    .then(
        setTimeout(() => {
            player.play();
        }, 1000)
    )
    .catch((error) => {
        console.error(error);
    });
kaeruB commented 3 days ago

I have a similar issue that might be related to loadVideo function. I also have a set of videos.

The problem on my website is as follows: after switching between videos and clicking the back button in the browser, I always get:

image image

You can also see that type of error on the video that is provided in the issue description as well. If you try to replicate it with the code provided in the issue, you can see that after the error appears, the player also doesn't load any other video by clicking next or previous buttons. cannot play gif

Also, I see this library error in the console (I haven't seen this error last week, seems to be new one):

image

image

I tried to add "player.vimeo.com" to allowed domains and the privacy errors disappears, but hitting the browser's back button still blocks loading any different video on the website. The behavior is as follows:

  1. click the back button
  2. click any other video from a list of videos
  3. the player doesn't load a different video, plays the same one

Some of my thoughts:

Our project uses the latest version of the library @vimeo/player": "2.23.0".

kaeruB commented 3 days ago

One more comment that might be useful in the investigation - here is a healthy request example when there is no problem with loading a video:

image

and here is a request when the privacy error happens:

image

You can see that Content-Security-Policy part is different.