correctly save the playlist if songs are removed and dont load the player outisde the media app if the playlist is empty

This commit is contained in:
Robin Appelman 2011-08-03 14:23:35 +02:00
parent a84b00cefc
commit 8e5184a8b9
3 changed files with 21 additions and 17 deletions

View File

@ -51,7 +51,7 @@ $(document).ready(function() {
} }
if(typeof PlayList==='undefined'){ if(typeof PlayList==='undefined'){
if(typeof localStorage !== 'undefined'){ if(typeof localStorage !== 'undefined'){
if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_items')){ if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_items' && localStorage.getItem(oc_current_user+'oc_playlist_items')!='[]'){
loadPlayer(); loadPlayer();
} }
} }

View File

@ -142,6 +142,7 @@ var PlayList={
remove:function(index){ remove:function(index){
PlayList.items.splice(index,1); PlayList.items.splice(index,1);
PlayList.render(); PlayList.render();
PlayList.save();
}, },
render:function(){}, render:function(){},
playing:function(){ playing:function(){
@ -160,6 +161,7 @@ var PlayList={
if(typeof localStorage !== 'undefined'){ if(typeof localStorage !== 'undefined'){
if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_items')){ if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_items')){
PlayList.items=JSON.parse(localStorage.getItem(oc_current_user+'oc_playlist_items')); PlayList.items=JSON.parse(localStorage.getItem(oc_current_user+'oc_playlist_items'));
if(PlayList.items.length>0){
PlayList.current=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_current')); PlayList.current=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_current'));
var time=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_time')); var time=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_time'));
if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_volume')){ if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_volume')){
@ -182,3 +184,4 @@ var PlayList={
} }
} }
} }
}

View File

@ -135,6 +135,7 @@ function procesSelection(){
}); });
PlayList.items=PlayList.items.filter(function(item){return item!==null}); PlayList.items=PlayList.items.filter(function(item){return item!==null});
PlayList.render(); PlayList.render();
PlayList.save();
procesSelection(); procesSelection();
}); });
} }