I've been struggling for a while to include a Plyr library (read & customise audio src) and I need to embed it via requireJS (important). all the other libraries work except this one, I wonder what's wrong!
Error: (console)
Uncaught TypeError: Plyr is not a constructor
Here is an example working without RequireJS, maybe it cool help. JsFiddle
My JsFiddle example :
html:
<audio crossorigin playsinline>
<source src="https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3" type="audio/mp3">
<source src="https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg" type="audio/ogg">
</audio>
Js:
requirejs.config({
paths: {
jquery: 'https://code.jquery.com/jquery-3.6.3.min',
plyr: 'https://cdn.plyr.io/3.7.3/plyr'
},
shim: {
"plyr": {
deps: ["jquery"]
}
}
});
require(['jquery','plyr'], function($, Plyr) {
'use strict';
const player = new Plyr("audio", {});
window.player = player;
});