diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-08-01 01:12:28 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-08-01 01:12:28 +0200 |
commit | 76a2f5b5476c87d330cb81a25793461554af416a (patch) | |
tree | 9c7244c0cd5a4d58c87b061c83a05c4163dc254f | |
parent | cbf8f822de35748e079df695dd322ada32d02f69 (diff) | |
download | nextcloud-server-76a2f5b5476c87d330cb81a25793461554af416a.tar.gz nextcloud-server-76a2f5b5476c87d330cb81a25793461554af416a.zip |
persistent playlist for the media player
-rw-r--r-- | apps/media/js/files.js | 5 | ||||
-rw-r--r-- | apps/media/js/music.js | 1 | ||||
-rw-r--r-- | apps/media/js/player.js | 23 |
3 files changed, 28 insertions, 1 deletions
diff --git a/apps/media/js/files.js b/apps/media/js/files.js index 307c6012a26..79741e19703 100644 --- a/apps/media/js/files.js +++ b/apps/media/js/files.js @@ -47,4 +47,9 @@ $(document).ready(function() { FileActions.register('application/ogg','','Play',playAudio); FileActions.setDefault('audio','Play'); FileActions.setDefault('application/ogg','Play'); + if(typeof localStorage !== 'undefined'){ + if(localStorage.hasOwnProperty('oc_playlist_items')){ + loadPlayer(); + } + } });
\ No newline at end of file diff --git a/apps/media/js/music.js b/apps/media/js/music.js index 3dee87744fe..90b5a098002 100644 --- a/apps/media/js/music.js +++ b/apps/media/js/music.js @@ -41,6 +41,7 @@ $(document).ready(function(){ }); row.find('div.name').append(button); } + PlayList.init(); }); diff --git a/apps/media/js/player.js b/apps/media/js/player.js index 1243f20b8ed..d79d6135df2 100644 --- a/apps/media/js/player.js +++ b/apps/media/js/player.js @@ -33,11 +33,13 @@ var PlayList={ PlayList.player.jPlayer("setMedia", PlayList.items[PlayList.current]); PlayList.items[index].playcount++; PlayList.player.jPlayer("play"); - if(Collection){ + if (typeof Collection !== 'undefined') { Collection.registerPlay(); } } }else{ + localStorage.setItem('oc_playlist_current',PlayList.current); + localStorage.setItem('oc_playlist_playing','true'); PlayList.init(PlayList.items[index].type,PlayList.play); } } @@ -62,6 +64,7 @@ var PlayList={ ended:PlayList.next, supplied:type, ready:function(){ + PlayList.load(); if(ready){ ready(); } @@ -93,6 +96,7 @@ var PlayList={ item[type]=PlayList.urlBase+encodeURIComponent(song.song_path); PlayList.items.push(item); } + PlayList.save(); }, addFile:function(path){ var type=musicTypeFromFile(path); @@ -116,5 +120,22 @@ var PlayList={ }else{ return !PlayList.player.data("jPlayer").status.paused; } + }, + save:function(){ + if(typeof localStorage !== 'undefined'){ + localStorage.setItem('oc_playlist_items',JSON.stringify(PlayList.items)); + } + }, + load:function(){ + if(typeof localStorage !== 'undefined'){ + if(localStorage.hasOwnProperty('oc_playlist_items')){ + PlayList.items=JSON.parse(localStorage.getItem('oc_playlist_items')); + PlayList.current=parseInt((localStorage.getItem('oc_playlist_current'))); + if(JSON.parse(localStorage.getItem('oc_playlist_playing'))){ + PlayList.play(); + } + PlayList.render(); + } + } } } |