0

I am trying to add custom js file using my custom module. But getting below error in console.

Uncaught ReferenceError: Plyr is not defined
DevTools failed to load SourceMap: Could not load content for http://localhost/magento/pub/static/version1592134088/frontend/Magento/luma/en_US/Vendor_Module/js/plyr.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

My code:

app\code\Vendor\Modle\view\frontend\requirejs-config.js

var config = {
    map: {
        '*': {
            plyr: 'Vendor_Module/js/plyr'
        }
    }
};

On phtml file

<script type="text/javascript">
require(['jquery','plyr'],function($){
    const player = new Plyr('#player1', {
        fullscreen:{ enabled: true, fallback: true, iosNative: true },
        controls:['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen', 'download']
    });
});
</script>

Does anyone have any solution? Thanks in advance.

3
  • did you delete static content? and deploy again?
    – Sohel Rana
    Commented Jun 14, 2020 at 12:26
  • Yes, did run all commands that required.
    – Nayem323
    Commented Jun 14, 2020 at 12:36
  • where you put your js file can you mention path here ? Commented Jun 15, 2020 at 6:36

1 Answer 1

0

One minor error in .phtml file and that should be like bellow:

<script type="text/javascript">
      require(['jquery','plyr'],function($,plyr){
        // logic here
      });
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.