diff --git a/apps/media/js/loader.js b/apps/media/js/loader.js index 429ef742d1..5fc8a7bce4 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_current_user+'oc_playlist_items')){ + if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_items' && localStorage.getItem(oc_current_user+'oc_playlist_items')!='[]'){ loadPlayer(); } } diff --git a/apps/media/js/player.js b/apps/media/js/player.js index b6d3bc01dd..6d585e6e09 100644 --- a/apps/media/js/player.js +++ b/apps/media/js/player.js @@ -142,6 +142,7 @@ var PlayList={ remove:function(index){ PlayList.items.splice(index,1); PlayList.render(); + PlayList.save(); }, render:function(){}, playing:function(){ @@ -160,24 +161,26 @@ var PlayList={ if(typeof localStorage !== 'undefined'){ 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')); - var time=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_time')); - if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_volume')){ - var volume=localStorage.getItem(oc_current_user+'oc_playlist_volume'); - PlayList.volume=volume/100; - $('.jp-volume-bar-value').css('width',volume+'%'); - if(PlayList.player.data('jPlayer')){ - PlayList.player.jPlayer("option",'volume',volume/100); + if(PlayList.items.length>0){ + PlayList.current=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_current')); + var time=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_time')); + if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_volume')){ + var volume=localStorage.getItem(oc_current_user+'oc_playlist_volume'); + PlayList.volume=volume/100; + $('.jp-volume-bar-value').css('width',volume+'%'); + 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(); } } } diff --git a/apps/media/js/playlist.js b/apps/media/js/playlist.js index 54fe5b792e..a15c34f93f 100644 --- a/apps/media/js/playlist.js +++ b/apps/media/js/playlist.js @@ -135,6 +135,7 @@ function procesSelection(){ }); PlayList.items=PlayList.items.filter(function(item){return item!==null}); PlayList.render(); + PlayList.save(); procesSelection(); }); }