aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-07-30 00:21:24 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-07-30 00:21:24 +0200
commit93dd1c57ccc68ec36b6a1deba5af2026990b2e4c (patch)
treee80985971f49c4ddfcb983f968db75c49487a90a /apps
parentaa7c6f057bafceabfcfcedf8882044921e96f53b (diff)
downloadnextcloud-server-93dd1c57ccc68ec36b6a1deba5af2026990b2e4c.tar.gz
nextcloud-server-93dd1c57ccc68ec36b6a1deba5af2026990b2e4c.zip
update playcount correctly without having to reload the collection
Diffstat (limited to 'apps')
-rw-r--r--apps/media/index.php1
-rw-r--r--apps/media/js/collection.js21
-rw-r--r--apps/media/js/player.js4
3 files changed, 22 insertions, 4 deletions
diff --git a/apps/media/index.php b/apps/media/index.php
index bd994e06341..0fe7c12f63c 100644
--- a/apps/media/index.php
+++ b/apps/media/index.php
@@ -39,7 +39,6 @@ OC_UTIL::addScript('media','playlist');
OC_UTIL::addScript('media','collection');
OC_UTIL::addScript('media','jquery.jplayer.min');
OC_UTIL::addStyle('media','player');
-OC_UTIL::addStyle('media','playlist');
OC_UTIL::addStyle('media','music');
OC_APP::setActiveNavigationEntry( 'media_playlist' );
diff --git a/apps/media/js/collection.js b/apps/media/js/collection.js
index 0a6e0e4eb3f..5aa0d058bdc 100644
--- a/apps/media/js/collection.js
+++ b/apps/media/js/collection.js
@@ -23,7 +23,6 @@ Collection={
for(var w=0;w<album.songs.length;w++){
album.songs[w].album_name=album.album_name;
album.songs[w].artist_name=artist.artist_name;
- album.songs[w].artist_name=artist.artist_name;
}
}
}
@@ -101,14 +100,30 @@ Collection={
var li=template.clone();
var song=album.songs[i];
li.removeClass('template');
- li.addClass('song',song);
+ li.addClass('song');
+ li.data('song',song);
li.children('span').text(song.song_name);
li.children('button').click(function(){
- PlayList.add($(this).parent().data('span'));
+ PlayList.add($(this).parent().data('song'));
})
ul.append(li);
}
albumLi.append(ul);
+ },
+ registerPlay:function(){
+ var item=PlayList.items[PlayList.current];
+ for(var i=0;i<Collection.artists.length;i++){
+ var artist=Collection.artists[i];
+ for(var j=0;j<artist.albums.length;j++){
+ var album=artist.albums[j]
+ for(var w=0;w<album.songs.length;w++){
+ var song=album.songs[w];
+ if(song.song_name==item.name && song.artist_name==item.artist && song.album_name==item.album){
+ song.song_playcount++;
+ }
+ }
+ }
+ }
}
}
diff --git a/apps/media/js/player.js b/apps/media/js/player.js
index 7beb01b6013..2e910bc0d59 100644
--- a/apps/media/js/player.js
+++ b/apps/media/js/player.js
@@ -31,7 +31,11 @@ var PlayList={
PlayList.init(PlayList.items[index].type,PlayList.play);
}else{
PlayList.player.jPlayer("setMedia", PlayList.items[PlayList.current]);
+ PlayList.items[index].playcount++;
PlayList.player.jPlayer("play");
+ if(Collection){
+ Collection.registerPlay();
+ }
}
}else{
PlayList.init(PlayList.items[index].type,PlayList.play);