Infer name from url

This commit is contained in:
Jordan Eldredge 2015-03-28 22:09:07 -04:00
parent 06b3412e4f
commit f492da6abd
3 changed files with 10 additions and 5 deletions

View file

@ -2,7 +2,7 @@
<body>
<script src='embed.min.js'
data-media="https://cdn.rawgit.com/captbaritone/llama/master/llama-2.91.mp3"
data-filename= "1. DJ Mike Llama - Llama Whippin' Intro"
data-filename="1. DJ Mike Llama - Llama Whippin' Intro"
></script>
</body>
</html>

View file

@ -42,8 +42,7 @@ var initFromTemplate = function (template) {
'volume': 50,
'balance': 0,
'mediaFile': {
'url': scriptTag.dataset.media,
'name': scriptTag.dataset.trackname
'url': scriptTag.dataset.media
},
'skinUrl': 'https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/base-2.91.wsz'
});

View file

@ -31,7 +31,8 @@ Winamp = {
this.setVolume(options.volume);
this.setBalance(options.balance);
this.loadFromUrl(options.mediaFile.url, options.mediaFile.name);
var filename = options.mediaFile.name ? options.mediaFile.name : false;
this.loadFromUrl(options.mediaFile.url, filename);
var skinFile = new MyFile();
skinFile.setUrl(options.skinUrl);
this.setSkin(skinFile);
@ -219,7 +220,12 @@ Winamp = {
// Used only for the initial load, since it must have a CORS header
loadFromUrl: function(url, fileName) {
this.fileName = fileName;
if(fileName) {
this.fileName = fileName;
} else {
this.fileName = url.split('/').pop();
}
var file = new MyFile();
file.setUrl(url);
file.processBuffer(this._loadBuffer.bind(this));