Plyr: RequireJS and Plyr

Created on 10 Apr 2018  路  5Comments  路  Source: sampotts/plyr

If I use RequireJS and Plyr, I didn't receive the Plyr instance:

Example: (Lock at the console output)

https://s.codepen.io/jonnitto/debug/zWeGjz/LQkExPzbXpYA

<script src='https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.js'></script>
<script >
require(["https://cdn.plyr.io/3.1.0/plyr.js"], function () {
  console.log('3.1.0', arguments);
});

require(["https://cdn.plyr.io/2.0.18/plyr.js"], function () {
  console.log('2.0.18', arguments);
});
</script>

All 5 comments

That's because that way doesn't work with named modules I think.

<script src='https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.js'></script>
<script src="https://cdn.plyr.io/3.1.0/plyr.js"></script>
<script>
require(["Plyr"], function () {
  console.log('3.1.0', arguments);
});
</script>

I'm not massively familiar with require but sounds like you have your solution? If so, can you please close this one.

I still have to figure it out. I鈥榲e to support our old UI in the Neos Plugin. I think the post @friday made will help, but I can鈥榯 use the code 1:1. I鈥榣l close this issue as soon as I have a solution.

I'm also not that well acquainted with requirejs. I tried searching for "requirejs external named modules" for example, but with no luck. This strikes me as a pretty basic use case, but still nothing. If requirejs still has a decent number of users out there, you could probably find help on stackoverflow and similar places.

This should work too:

require(["https://cdn.plyr.io/3.1.0/plyr.js"], function () {
  require(["Plyr"], function () {
    console.log('3.1.0', arguments);
  });
});

Feels like a hack rather than a solution though.

I found the same solution. Released Plyr 3 for Neos.io: https://github.com/jonnitto/Jonnitto.Plyr and https://github.com/jonnitto/Jonnitto.TextWithPlyr

Was this page helpful?
0 / 5 - 0 ratings

Related issues

onigetoc picture onigetoc  路  3Comments

sparkktv picture sparkktv  路  4Comments

frumbert picture frumbert  路  3Comments

nam-co picture nam-co  路  4Comments

Generalomosco picture Generalomosco  路  3Comments