From ef22498c6f9a7c378d7a7be3fb4df9ac09a14021 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 1 Aug 2011 01:56:45 +0200 Subject: [PATCH] some fixes for persistent playlists --- apps/media/js/loader.js | 2 +- apps/media/js/music.js | 9 +++++---- apps/media/js/player.js | 16 ++++++++-------- core/templates/layout.admin.php | 1 + core/templates/layout.user.php | 1 + 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/media/js/loader.js b/apps/media/js/loader.js index 9eb51113f3..429ef742d1 100644 --- a/apps/media/js/loader.js +++ b/apps/media/js/loader.js @@ -51,7 +51,7 @@ $(document).ready(function() { } if(typeof PlayList==='undefined'){ if(typeof localStorage !== 'undefined'){ - if(localStorage.hasOwnProperty('oc_playlist_items')){ + if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_items')){ loadPlayer(); } } diff --git a/apps/media/js/music.js b/apps/media/js/music.js index 90b5a09800..d551127971 100644 --- a/apps/media/js/music.js +++ b/apps/media/js/music.js @@ -13,9 +13,11 @@ $(document).ready(function(){ Collection.hide(); }); var tab=window.location.href.slice(window.location.href.indexOf('#') + 1); - if(tab=='collection'){ - $('#plugins a[href="#collection"]').trigger('click'); - } + PlayList.init('mp3',function(){ + if(tab=='collection'){ + $('#plugins a[href="#collection"]').trigger('click'); + } + }); OC.search.customResults.Music=function(row,item){ var parts=item.link.substr(item.link.indexOf('#')+1).split('&'); var data={}; @@ -41,7 +43,6 @@ $(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 6dee7b0ac2..8ef85f4848 100644 --- a/apps/media/js/player.js +++ b/apps/media/js/player.js @@ -33,9 +33,9 @@ var PlayList={ PlayList.player.jPlayer("setMedia", PlayList.items[PlayList.current]); PlayList.items[index].playcount++; PlayList.player.jPlayer("play"); - localStorage.setItem('oc_playlist_current',index); - localStorage.setItem('oc_playlist_playing','true'); - if(index>=0){ + localStorage.setItem(oc_current_user+'oc_playlist_current',index); + localStorage.setItem(oc_current_user+'oc_playlist_playing','true'); + if(index>0){ var previous=index-1; }else{ var previous=PlayList.items.length-1; @@ -135,15 +135,15 @@ var PlayList={ }, save:function(){ if(typeof localStorage !== 'undefined'){ - localStorage.setItem('oc_playlist_items',JSON.stringify(PlayList.items)); + localStorage.setItem(oc_current_user+'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'))){ + if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_items')){ + PlayList.items=JSON.parse(localStorage.getItem(oc_current_user+'oc_playlist_items')); + PlayList.current=parseInt((localStorage.getItem(oc_current_user+'oc_playlist_current'))); + if(JSON.parse(localStorage.getItem(oc_current_user+'oc_playlist_playing'))){ PlayList.play(); } PlayList.render(); diff --git a/core/templates/layout.admin.php b/core/templates/layout.admin.php index 3aac4c98ac..be4419af84 100644 --- a/core/templates/layout.admin.php +++ b/core/templates/layout.admin.php @@ -9,6 +9,7 @@ diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 1de0ccf80c..33de9d5f72 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -9,6 +9,7 @@