diff --git a/.gitignore b/.gitignore
index c404673..936424e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,3 @@
dist/js/*.js
dist/css/*.css
dist/css/*.svg
-package-lock.json
-node_modules
diff --git a/.minify.json b/.minify.json
deleted file mode 100644
index 688c84f..0000000
--- a/.minify.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "js": {
- "type": "terser",
- "terser": {
- "mangle": false
- }
- }
-}
diff --git a/package.json b/package.json
deleted file mode 100644
index 41d325d..0000000
--- a/package.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "myplayer",
- "version": "1.0.0",
- "description": "A Web-MP3-Player with Playlist Support",
- "main": "src/player.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "repository": {
- "type": "git",
- "url": "https://tk-sls.de/git/tk-sls.de/myplayer.git"
- },
- "author": "tilt ",
- "license": "MIT",
- "dependencies": {
- "minify": "^11.4.1"
- }
-}
diff --git a/src/build.sh b/src/build.sh
index ec764c6..0811388 100755
--- a/src/build.sh
+++ b/src/build.sh
@@ -12,8 +12,8 @@ if ! cd "$dir" ; then
elif ! mkdir -p "$jsdir" ; then
echo "ERROR: Could not create directory $jsdir; aborted." >&2 ;
exit 1 ;
-elif ! type minify > /dev/null ; then
- echo "ERROR: Executable \"minify\" not found in PATH; aborted." >&2 ;
+elif ! type yui-compressor > /dev/null ; then
+ echo "ERROR: Executable \"yui-compressor\" not found in PATH; aborted." >&2 ;
exit 1 ;
fi
@@ -47,7 +47,7 @@ do
done
echo "INFO: Compressing player.js ..." >&2
-minify player.js >> "$jsdir"/myplayer.min.js
+yui-compressor player.js >> "$jsdir"/myplayer.min.js
chmod 644 "$jsdir"/myplayer.min.js
diff --git a/src/player.js b/src/player.js
index a6ba9ed..740cf23 100644
--- a/src/player.js
+++ b/src/player.js
@@ -6,7 +6,7 @@
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
@@ -21,427 +21,401 @@
* THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE */
var MyPlayer = function(_args) {
- var failed = false,
- detached = false,
- player = null,
- args_default = {
- autoplay: false,
- css: { "height": "500px" },
- detachable: true,
- element: "body",
- id3: false,
- list: [],
- loop: true,
- mode: "mp3url",
- shuffle: false,
- waveform: false
- },
- args = (_args===undefined) ? args_default : $.extend({}, args_default, _args),
- mimeTypeFromSrc = function(src) {
- var extension = src.split(".").pop().toLowerCase();
+ var failed = false;
+ var detached = false;
+ var player = null;
- var types = {
- "3g2": "video/3gpp2",
- "3gp": "video/3gpp",
- "7z": "application/x-7z-compressed",
- "aac": "audio/aac",
- "abw": "application/x-abiword",
- "arc": "application/x-freearc",
- "avi": "video/x-msvideo",
- "azw": "application/vnd.amazon.ebook",
- "bin": "application/octet-stream",
- "bmp": "image/bmp",
- "bz": "application/x-bzip",
- "bz2": "application/x-bzip2",
- "cda": "application/x-cdf",
- "csh": "application/x-csh",
- "css": "text/css",
- "csv": "text/csv",
- "doc": "application/msword",
- "eot": "application/vnd.ms-fontobject",
- "epub": "application/epub+zip",
- "gif": "image/gif",
- "gz": "application/gzip",
- "htm": "text/html",
- "html": "text/html",
- "ico": "image/vnd.microsoft.icon",
- "ics": "text/calendar",
- "jar": "application/java-archive",
- "jpeg": "image/jpeg",
- "jpg": "image/jpeg",
- "js": "text/javascript",
- "json": "application/json",
- "jsonld": "application/ld+json",
- "mid": "audio/midi audio/x-midi",
- "midi": "audio/midi audio/x-midi",
- "mjs": "text/javascript",
- "mp3": "audio/mpeg",
- "mp4": "video/mp4",
- "mpeg": "video/mpeg",
- "mpkg": "application/vnd.apple.installer+xml",
- "odp": "application/vnd.oasis.opendocument.presentation",
- "ods": "application/vnd.oasis.opendocument.spreadsheet",
- "odt": "application/vnd.oasis.opendocument.text",
- "oga": "audio/ogg",
- "ogv": "video/ogg",
- "ogx": "application/ogg",
- "opus": "audio/opus",
- "otf": "font/otf",
- "pdf": "application/pdf",
- "php": "application/x-httpd-php",
- "png": "image/png",
- "ppt": "application/vnd.ms-powerpoint",
- "rar": "application/vnd.rar",
- "rtf": "application/rtf",
- "sh": "application/x-sh",
- "svg": "image/svg+xml",
- "swf": "application/x-shockwave-flash",
- "tar": "application/x-tar",
- "tif": "image/tiff",
- "tiff": "image/tiff",
- "ts": "video/mp2t",
- "ttf": "font/ttf",
- "txt": "text/plain",
- "vsd": "application/vnd.visio",
- "wav": "audio/wav",
- "weba": "audio/webm",
- "webm": "video/webm",
- "webp": "image/webp",
- "woff": "font/woff",
- "woff2": "font/woff2",
- "xhtml": "application/xhtml+xml",
- "xls": "application/vnd.ms-excel",
- "xml": "application/xml",
- "xul": "application/vnd.mozilla.xul+xml",
- "zip": "application/zip"
- };
+ var defaultArgs = {
+ detachable: true,
+ element: 'body',
+ id3: false,
+ mode: 'mp3url',
+ waveform: false,
+ autoplay: false,
+ loop: true,
+ shuffle: false,
+ list: []
+ };
- return types[extension] || "application/octet-stream";
- },
- createAudio = function() {
- var autoplay = args.autoplay ? 'autoplay="true"' : '';
- var styles = [];
- var style;
- var key;
+ var mimeTypeFromSrc = function(src) {
+ var extension = src.split('.').pop().toLowerCase();
- for (key in args.css) {
- var value = args.css[key];
- styles.push(`${key}: ${value}`);
+ return {
+ "aac": "audio/aac",
+ "abw": "application/x-abiword",
+ "arc": "application/x-freearc",
+ "avi": "video/x-msvideo",
+ "azw": "application/vnd.amazon.ebook",
+ "bin": "application/octet-stream",
+ "bmp": "image/bmp",
+ "bz": "application/x-bzip",
+ "bz2": "application/x-bzip2",
+ "cda": "application/x-cdf",
+ "csh": "application/x-csh",
+ "css": "text/css",
+ "csv": "text/csv",
+ "doc": "application/msword",
+ "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
+ "eot": "application/vnd.ms-fontobject",
+ "epub": "application/epub+zip",
+ "gz": "application/gzip",
+ "gif": "image/gif",
+ "htm": "text/html",
+ "html": "text/html",
+ "ico": "image/vnd.microsoft.icon",
+ "ics": "text/calendar",
+ "jar": "application/java-archive",
+ "jpeg": "image/jpeg",
+ "jpg": "image/jpeg",
+ "js": "text/javascript",
+ "json": "application/json",
+ "jsonld": "application/ld+json",
+ "mid": "audio/midi audio/x-midi",
+ "midi": "audio/midi audio/x-midi",
+ "mjs": "text/javascript",
+ "mp3": "audio/mpeg",
+ "mp4": "video/mp4",
+ "mpeg": "video/mpeg",
+ "mpkg": "application/vnd.apple.installer+xml",
+ "odp": "application/vnd.oasis.opendocument.presentation",
+ "ods": "application/vnd.oasis.opendocument.spreadsheet",
+ "odt": "application/vnd.oasis.opendocument.text",
+ "oga": "audio/ogg",
+ "ogv": "video/ogg",
+ "ogx": "application/ogg",
+ "opus": "audio/opus",
+ "otf": "font/otf",
+ "png": "image/png",
+ "pdf": "application/pdf",
+ "php": "application/x-httpd-php",
+ "ppt": "application/vnd.ms-powerpoint",
+ "pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
+ "rar": "application/vnd.rar",
+ "rtf": "application/rtf",
+ "sh": "application/x-sh",
+ "svg": "image/svg+xml",
+ "swf": "application/x-shockwave-flash",
+ "tar": "application/x-tar",
+ "tif": "image/tiff",
+ "tiff": "image/tiff",
+ "ts": "video/mp2t",
+ "ttf": "font/ttf",
+ "txt": "text/plain",
+ "vsd": "application/vnd.visio",
+ "wav": "audio/wav",
+ "weba": "audio/webm",
+ "webm": "video/webm",
+ "webp": "image/webp",
+ "woff": "font/woff",
+ "woff2": "font/woff2",
+ "xhtml": "application/xhtml+xml",
+ "xls": "application/vnd.ms-excel",
+ "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ "xml": "application/xml",
+ "xul": "application/vnd.mozilla.xul+xml",
+ "zip": "application/zip",
+ "3gp": "video/3gpp",
+ "3g2": "video/3gpp2",
+ "7z": "application/x-7z-compressed"
+ }[extension] || "application/octet-stream";
+ };
+
+ var args = (typeof(_args)==='undefined')
+ ? defaultArgs
+ : $.extend({}, defaultArgs, _args);
+
+ var createAudio = function() {
+ var autoplay = args.autoplay ? 'autoplay="true"' : '';
+
+ $(args.element).append(
+ ''
+ );
+
+ args.audio = args.element + ' audio';
+
+ $(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(' ');
+
+ 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;
+
+ $(args.element).find('ul.mejs li').each(function(j, _track){
+ if(i==j)
+ $(_track).html(track_title);
+ });
}
+ });
+ });
+ };
- style = styles.join(" ");
- args.audio = $(``);
- console.log("DEBUG: appending audio=", args.audio, " to element=", args.element, " ...");
- $(args.element).append(args.audio);
- },
- readId3 = function() {
- $(args.element).find('ul.mejs li').each(function(i, track){
- var url = $(track).attr('data-url');
+ var playerCreated = function() {
+ restoreParams();
+
+ if(args.id3)
+ readId3();
+ };
- $(track).prepend(' ');
+ var createPlayer = function() {
+ player = new MediaElementPlayer(
+ "myplayer", {
+ success: playerCreated,
+ features: ['playpause', 'current', 'progress', 'duration', 'volume', 'playlist', 'prevtrack', 'nexttrack', 'shuffle', 'loop']
+ });
- jsmediatags.read(url, {
- onSuccess: function(tag) {
- var tags = tag.tags;
- var track_title;
+ $(args.element).append(
+ ''+
+ 'The player is currently detached.'+
+ '
'
+ );
+ };
- if(typeof(tags.title)!='undefined') {
- track_title = tags.title;
- }
- else {
- track_title = url;
- }
+ var param = function(name) {
+ var query = window.location.search.substring(1);
+ var vars = query.split("&");
- if(typeof(tags.artist)!='undefined') {
- track_title = tags.artist + ' - ' + track_title;
- }
+ for(var i=0; i'+
- 'The player is currently detached.'+
- '
'
- );
- },
- param = function(name) {
- var query = window.location.search.substring(1);
- var vars = query.split("&");
+ var playerWindow = window.open(
+ url, 'myplayer',
+ 'height='+ Math.max($(args.element).height(), 298)+','+
+ 'width='+408+','+
+ 'resizable=false'
+ );
- for(i=0; i