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

remotes/origin/stable
Robin Appelman 14 years ago
parent a84b00cefc
commit 8e5184a8b9
  1. 2
      apps/media/js/loader.js
  2. 35
      apps/media/js/player.js
  3. 1
      apps/media/js/playlist.js

@ -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();
} }
} }

@ -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,24 +161,26 @@ 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'));
PlayList.current=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_current')); if(PlayList.items.length>0){
var time=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_time')); PlayList.current=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_current'));
if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_volume')){ var time=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_time'));
var volume=localStorage.getItem(oc_current_user+'oc_playlist_volume'); if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_volume')){
PlayList.volume=volume/100; var volume=localStorage.getItem(oc_current_user+'oc_playlist_volume');
$('.jp-volume-bar-value').css('width',volume+'%'); PlayList.volume=volume/100;
if(PlayList.player.data('jPlayer')){ $('.jp-volume-bar-value').css('width',volume+'%');
PlayList.player.jPlayer("option",'volume',volume/100); if(PlayList.player.data('jPlayer')){
PlayList.player.jPlayer("option",'volume',volume/100);
}
} }
if(JSON.parse(localStorage.getItem(oc_current_user+'oc_playlist_playing'))){
PlayList.play(null,time);
}else{
PlayList.play(null,time,function(){
PlayList.player.jPlayer("pause");
});
}
PlayList.render();
} }
if(JSON.parse(localStorage.getItem(oc_current_user+'oc_playlist_playing'))){
PlayList.play(null,time);
}else{
PlayList.play(null,time,function(){
PlayList.player.jPlayer("pause");
});
}
PlayList.render();
} }
} }
} }

@ -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();
}); });
} }

Loading…
Cancel
Save