diff --git a/index.html b/index.html index 99c612f..c03fdc5 100644 --- a/index.html +++ b/index.html @@ -29,16 +29,24 @@ // test image for web notifications var iconImage = null; - AP.init({ - container:'#player',//a string containing one CSS selector - volume : 0.7, - autoPlay : true, - notification: false, - playList: [ - {'icon': iconImage, 'title': 'Try Everything', 'file': 'mp3/try-everything.mp3'}, - {'icon': iconImage, 'title': 'Let It Go', 'file': 'mp3/let-it-go.mp3'} - ] - }); + fetch("playlist.json") + .then(response => { + if (response.ok) { + return response.json() + } else { + throw Error('Loading playlist: ' + response.statusText) + } + }) + .then(playList => { + AP.init({ + container:'#player',//a string containing one CSS selector + volume : 0.7, + autoPlay : true, + notification: false, + playList: playList + }); + }) + .catch(error => alert(error)) diff --git a/playlist.json b/playlist.json new file mode 100644 index 0000000..6556a33 --- /dev/null +++ b/playlist.json @@ -0,0 +1,12 @@ +[ + { + "file" : "mp3/try-everything.mp3", + "icon" : null, + "title" : "Try Everything" + }, + { + "icon" : null, + "title" : "Let It Go", + "file" : "mp3/let-it-go.mp3" + } +]