mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-28 12:36:35 +00:00
Apply personal style to wsz skin PR
This commit is contained in:
parent
d5d00f78ed
commit
8cdd4504f1
2 changed files with 24 additions and 42 deletions
57
skin.js
57
skin.js
|
|
@ -34,52 +34,39 @@ SkinManager = function() {
|
|||
".shade #position::-moz-range-thumb": "TITLEBAR.BMP",
|
||||
}
|
||||
|
||||
// For local dev, we want to use the asset we have locally
|
||||
this.useLocalDefaultSkin = function() {
|
||||
self.setSkinByUrl('skins/base-2.91.wsz');
|
||||
}
|
||||
|
||||
// I have a collection of skins on GitHub to make loading remote skins
|
||||
// easier. rawgit.com changes this into a free CDN
|
||||
this.setSkinByName = function(name) {
|
||||
url = "https://cdn.rawgit.com/elliots/winamp2-js/master/skins/" + name + ".wsz";
|
||||
self.setSkinByUrl(url);
|
||||
}
|
||||
|
||||
// Given the url of an original Winamp WSZ file, set the current skin
|
||||
this.setSkinByUrl = function(url) {
|
||||
JSZipUtils.getBinaryContent(url, function(err, data) {
|
||||
if (err) {
|
||||
alert('Failed to load skin ' + url + ' : ' + err);
|
||||
}
|
||||
try {
|
||||
this._setSkinByDataBlob(data);
|
||||
} catch(e) {
|
||||
alert('Failed to load skin ' + url + ' : ' + e.message);
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
JSZipUtils.getBinaryContent(url, function(err, data) {
|
||||
// Given a raw blob of a Winamp WSZ file, set the current skin
|
||||
this._setSkinByDataBlob = function(data) {
|
||||
var zip = new JSZip(data);
|
||||
|
||||
if (err) {
|
||||
alert('Failed to load skin ' + url + ' : ' + err);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
var zip = new JSZip(data);
|
||||
|
||||
var style = document.getElementById('skin');
|
||||
var cssRules = '';
|
||||
for(var selector in self._skinImages) {
|
||||
var style = document.getElementById('skin');
|
||||
var cssRules = '';
|
||||
for(var selector in self._skinImages) {
|
||||
|
||||
var file = zip.filter(function (relativePath, file){
|
||||
return new RegExp("(^|/)" + self._skinImages[selector], 'i').test(relativePath)
|
||||
return new RegExp("(^|/)" + self._skinImages[selector], 'i').test(relativePath)
|
||||
})[0];
|
||||
|
||||
if (!file) {
|
||||
console.log("Warning: Couldn't find file:" + self._skinImages[selector])
|
||||
console.log("Warning: Couldn't find file:" + self._skinImages[selector])
|
||||
} else {
|
||||
var value = "background-image: url(data:image/bmp;base64," + btoa(file.asBinary()) + ")"
|
||||
cssRules += selector + "{" + value + "}\n";
|
||||
var value = "background-image: url(data:image/bmp;base64," + btoa(file.asBinary()) + ")"
|
||||
cssRules += selector + "{" + value + "}\n";
|
||||
}
|
||||
}
|
||||
style.appendChild(document.createTextNode(cssRules));
|
||||
|
||||
} catch(e) {
|
||||
alert('Failed to load skin ' + url + ' : ' + e.message);
|
||||
}
|
||||
})
|
||||
|
||||
style.appendChild(document.createTextNode(cssRules));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -480,8 +480,7 @@ volume = anchorArgument('volume', 50);
|
|||
balance = anchorArgument('volume', 0);
|
||||
file = anchorArgument('m', 'https://mediacru.sh/download/Q2HAoRHE-JvD.mp3');
|
||||
fileName = anchorArgument('name', "1. DJ Mike Llama - Llama Whippin' Intro (0:05)");
|
||||
skin = anchorArgument('skin', "base-2.91");
|
||||
skinUrl = anchorArgument('skin-url', false);
|
||||
skinUrl = anchorArgument('skin-url', 'https://cdn.rawgit.com/captbaritone/winamp2-js/master/skins/base-2.91.wsz');
|
||||
|
||||
winamp = new Winamp();
|
||||
// XXX These should be moved to a constructor, but I can't figure out how
|
||||
|
|
@ -489,8 +488,4 @@ winamp.setVolume(volume);
|
|||
winamp.setBalance(balance);
|
||||
winamp.loadFile(file, fileName);
|
||||
winamp.marqueeLoop();
|
||||
if(skinUrl) {
|
||||
winamp.skinManager.setSkinByUrl(skinUrl);
|
||||
} else {
|
||||
winamp.skinManager.setSkinByName(skin);
|
||||
}
|
||||
winamp.skinManager.setSkinByUrl(skinUrl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue