sampotts / plyr

A simple HTML5, YouTube and Vimeo player
https://plyr.io
MIT License
26.65k stars 2.93k forks source link

[V3][3.0.6] Error about privacy settings is thrown to console (Vimeo) #839

Closed yuriykuzin closed 6 years ago

yuriykuzin commented 6 years ago

Please check this codepen: https://codepen.io/yuriyku/pen/ZxaNPa

An error is thrown to console, but the video is still playing:

Uncaught (in promise) Error: The URL is not available because of the video’s privacy settings. at player.js:2 at Array.forEach () at y (player.js:2) at u (player.js:2)

If I switch off Plyr (comment line const player = new Plyr('#player');), vimeo native player works properly.

Expected behaviour

No error in console.

Environment

Steps to reproduce

Open the codepen and console

sampotts commented 6 years ago

I'd say that's probably a bug with Vimeo's API, player.js?

yuriykuzin commented 6 years ago

It could be. But there is no such error when I turn Plyr off and use only player.js, as I mentioned above.

yuriykuzin commented 6 years ago

@sampotts Can you please do a hotfix?

File:

src/js/plugins/vimeo.js

Change this:

player.embed.getVideoUrl().then(value => {
            currentSrc = value;
        });

To this:

player.embed.getVideoUrl()
    .then(value => {
        currentSrc = value;
    })
    .catch(() => {
        // Do nothing
    });

Explanation:

On a private video vimeo throws an error on calling getVideoUrl. And even with this catch, you will be still able to catch an error using .on('error'..., so it is quite safe

sampotts commented 6 years ago

Sure - will do this shortly

yuriykuzin commented 6 years ago

Thanks! I appreciate your fast responses! :)

sampotts commented 6 years ago

Fixed in v3.0.8 👍