From 36773fe342150945db41e45ecb25393b62c33bb5 Mon Sep 17 00:00:00 2001 From: tilt12345678 Date: Sun, 10 Nov 2024 15:08:12 +0100 Subject: [PATCH] fix problems reported by eslint --- eslint.config.js | 10 ++++++++++ src/player.js | 46 +++++++++++++++++++++++++--------------------- 2 files changed, 35 insertions(+), 21 deletions(-) create mode 100644 eslint.config.js diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..11d4c2a --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,10 @@ +// eslint.config.js +export default [ + { + rules: { + semi: "error", + "prefer-const": "error" + } + } +]; + diff --git a/src/player.js b/src/player.js index 6b16678..740cf23 100644 --- a/src/player.js +++ b/src/player.js @@ -118,7 +118,7 @@ var MyPlayer = function(_args) { "3g2": "video/3gpp2", "7z": "application/x-7z-compressed" }[extension] || "application/octet-stream"; - } + }; var args = (typeof(_args)==='undefined') ? defaultArgs @@ -141,38 +141,42 @@ var MyPlayer = function(_args) { $(args.audio).css({ 'height': '500px', }); - } + }; var readId3 = function() { $(args.element).find('ul.mejs li').each(function(i, track){ var url = $(track).attr('data-url'); $(track).prepend('  '); - - ID3.loadTags(url, function() { - var tags = ID3.getAllTags(url); - - if(typeof(tags.title)!='undefined') { - var track_title = tags.title; + + jsmediatags.read(url, { + onSuccess: function(tag) { + var tags = tag.tags; + var track_title; + + if(typeof(tags.title)!='undefined') + track_title = tags.title; + else + track_title = url; if(typeof(tags.artist)!='undefined') - track_title = tags.artist + ' - ' + track_title; + track_title = tags.artist + ' - ' + track_title; $(args.element).find('ul.mejs li').each(function(j, _track){ - if(i==j) - $(_track).html(track_title); + if(i==j) + $(_track).html(track_title); }); } }); }); - } + }; var playerCreated = function() { restoreParams(); if(args.id3) readId3(); - } + }; var createPlayer = function() { player = new MediaElementPlayer( @@ -186,7 +190,7 @@ var MyPlayer = function(_args) { 'The player is currently detached.'+ '

' ); - } + }; var param = function(name) { var query = window.location.search.substring(1); @@ -200,7 +204,7 @@ var MyPlayer = function(_args) { } return false; - } + }; var setupDetach = function() { if(!args.detachable) @@ -224,7 +228,7 @@ var MyPlayer = function(_args) { $("iframe",top.document).height(20); return false; - } + }; if(param('popup')==false) { $('.mejs-controls').append( @@ -255,7 +259,7 @@ var MyPlayer = function(_args) { 'currentTime='+currentTime+'&'+ 'volume='+volume+'&'+ 'trackNo='+trackNo - ) + ); }); } else { @@ -265,9 +269,9 @@ var MyPlayer = function(_args) { $("iframe", opener.top.document).height(windowHeight); $('.mejs-audio', opener.document).show(); $('.playerDetached', opener.document).hide(); - } + }; } - } + }; var restoreParams = function() { if(!detached) @@ -289,7 +293,7 @@ var MyPlayer = function(_args) { if(paused) player.pause(); - } + }; if(param('popup')!==false) { detached = true; @@ -413,5 +417,5 @@ var MyPlayer = function(_args) { $(args.element).append('

Unsupported mode "'+args.mode+'"

'); failed = true; } -} +};