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.

asked Jun 14, 2020 at 12:16
3
  • did you delete static content? and deploy again? Commented Jun 14, 2020 at 12:26
  • Yes, did run all commands that required. 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>
answered Jun 15, 2020 at 5:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.