]> source.dussan.org Git - nextcloud-server.git/commitdiff
correctly save the playlist if songs are removed and dont load the player outisde...
authorRobin Appelman <icewind1991@gmail.com>
Wed, 3 Aug 2011 12:23:35 +0000 (14:23 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Wed, 3 Aug 2011 12:23:35 +0000 (14:23 +0200)
apps/media/js/loader.js
apps/media/js/player.js
apps/media/js/playlist.js

index 429ef742d1a872706d746b3cb2a242fbd24a295c..5fc8a7bce40b982d8b5bb456b5dae6953dd1adae 100644 (file)
@@ -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();
                        }
                }
index b6d3bc01ddbe1989d2a89c4ad4f4f7cafd011c72..6d585e6e09448db8eed885271c87ca78c78fc58b 100644 (file)
@@ -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();
                        }
                }
        }
index 54fe5b792e7d8e9c8dff74019ea7eddaa7852db0..a15c34f93f9b518f7b757600a3bbbffc6f1cb45d 100644 (file)
@@ -135,6 +135,7 @@ function procesSelection(){
                        });
                        PlayList.items=PlayList.items.filter(function(item){return item!==null});
                        PlayList.render();
+                       PlayList.save();
                        procesSelection();
                });
        }