Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The cdn version of Vimeo's player.js is not appropriate for a <script> tag on a require.js-using site #420

Open
2 tasks
JodiWarren opened this issue Nov 10, 2016 · 6 comments

Comments

@JodiWarren
Copy link

JodiWarren commented Nov 10, 2016

Expected behaviour

Vimeo videos should play correctly

Actual behaviour

A Mismatched Anonymous Define Modules error fires. More info on that error: http://requirejs.org/docs/errors.html#mismatch

Basically, the UMD in player.js is simply not necessary for embedding via a script tag.

Environment

  • Browser: Chrome
  • Version: 54
  • Operating System: OSX
  • Version: 10.11.16

Steps to reproduce

  • Use Plyr.js on a site which uses require.js and load a Vimeo video.
@sampotts
Copy link
Owner

Might be worth raising this over at the player.js repo?
https://github.com/vimeo/player.js

@JodiWarren
Copy link
Author

@sampotts I've raised the above pull request for this issue. I'm not sure that that Vimeo would alter the CND'd version of their player.js for this. I think it could be related to this issue though: vimeo/player.js#36

I've implemented the above PR on a couple of Magento 2 sites, which heavily use require.js, and it thoroughly fixes the mentioned issue.

@JodiWarren
Copy link
Author

Here's a Codepen which kind of clumsily illustrates the issue: http://codepen.io/jodi/pen/ObMjbM?editors=1010

@JodiWarren
Copy link
Author

FWIW I've opened an issue on Vimeo's repo too: vimeo/player.js#79

Sorry for the issue spam!

@pgoforth
Copy link

This issue can be alleviated with a fix in the 'vimeoTimer' callback interval by checking for require and then load the CDN version using require if it's available:

var vimeoTimer = window.setInterval(function() {
    if (_is.object(window.Vimeo)) {
        window.clearInterval(vimeoTimer);
        _vimeoReady(mediaId, container);
    } else if ("function" == typeof define && define.amd) {
        require([
            config.urls.vimeo.api
        ], function(player){
            window.Vimeo = { Player: player };
            _vimeoReady(mediaId, container);
        });
        window.clearInterval(vimeoTimer);
    }
}, 50);

@friday friday changed the title The CND version of Vimeo's player.js is not appropriate for a <script> tag on a require.js-using site The cdn version of Vimeo's player.js is not appropriate for a <script> tag on a require.js-using site May 17, 2018
@friday
Copy link
Collaborator

friday commented May 29, 2018

If someone has issues with this (I'm not using require.js myself), a PR with an alternative method to load the URL is welcome. For example, you could detect if require.js exists globally and use it to load the URL instead of loadjs, like the solution above but in Plyr instead of a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants