summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-08-12 12:34:02 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-08-12 12:54:49 +0200
commit5a26640f638a1b259e6b9e1b580b1810e1efd015 (patch)
tree32c032408be7dcd3bd9cba3bd3a13789cfe3b50f
parent0b4ed2577676ee090812b9be76e00483217a062b (diff)
downloadnextcloud-server-5a26640f638a1b259e6b9e1b580b1810e1efd015.tar.gz
nextcloud-server-5a26640f638a1b259e6b9e1b580b1810e1efd015.zip
partly fix media player
-rw-r--r--apps/media/js/collection.js12
-rw-r--r--apps/media/js/player.js48
2 files changed, 37 insertions, 23 deletions
diff --git a/apps/media/js/collection.js b/apps/media/js/collection.js
index e49024973fa..95398f8397a 100644
--- a/apps/media/js/collection.js
+++ b/apps/media/js/collection.js
@@ -60,14 +60,14 @@ Collection={
tr.find('td.title a').text(song.song_name);
tr.find('td.title a').click(function(event){
event.preventDefault();
- PlayList.add(song);
- PlayList.render();
+ PlayList.add(song,true);
+ PlayList.play(0);
});
if(artist.artist_name!=lastArtist){
tr.find('td.artist a').click(function(event){
event.preventDefault();
- PlayList.add(artist);
- PlayList.render();
+ PlayList.add(artist,true);
+ PlayList.play(0);
});
tr.find('td.artist a').text(artist.artist_name);
if(artist.albums.length>1){
@@ -87,8 +87,8 @@ Collection={
if(album.album_name!=lastAlbum){
tr.find('td.album a').click(function(event){
event.preventDefault();
- PlayList.add(album);
- PlayList.render();
+ PlayList.add(album,true);
+ PlayList.play(0);
});
tr.find('td.album a').text(album.album_name);
if(album.songs.length>1){
diff --git a/apps/media/js/player.js b/apps/media/js/player.js
index 8298db56e61..d37196a89f5 100644
--- a/apps/media/js/player.js
+++ b/apps/media/js/player.js
@@ -5,48 +5,53 @@ var PlayList={
player:null,
volume:0.8,
active:false,
+ tempPlaylist:[],
+ isTemp:true,
next:function(){
+ var items=(PlayList.isTemp)?PlayList.tempPlaylist:PlayList.items;
var next=PlayList.current+1;
- if(next>=PlayList.items.length){
+ if(next>=items.length){
next=0;
}
PlayList.play(next);
PlayList.render();
},
previous:function(){
+ var items=(PlayList.isTemp)?PlayList.tempPlaylist:PlayList.items;
var next=PlayList.current-1;
if(next<0){
- next=PlayList.items.length-1;
+ next=items.length-1;
}
PlayList.play(next);
PlayList.render();
},
play:function(index,time,ready){
+ var items=(PlayList.isTemp)?PlayList.tempPlaylist:PlayList.items;
if(index==null){
index=PlayList.current;
}
- if(index>-1 && index<PlayList.items.length){
+ if(index>-1 && index<items.length){
PlayList.current=index;
if(PlayList.player){
- if(PlayList.player.data('jPlayer').options.supplied!=PlayList.items[index].type){//the the audio type changes we need to reinitialize jplayer
+ if(PlayList.player.data('jPlayer').options.supplied!=items[index].type){//the the audio type changes we need to reinitialize jplayer
PlayList.player.jPlayer("destroy");
- PlayList.init(PlayList.items[index].type,function(){PlayList.play(null,time,ready)});
+ PlayList.init(items[index].type,function(){PlayList.play(null,time,ready)});
}else{
- PlayList.player.jPlayer("setMedia", PlayList.items[PlayList.current]);
- PlayList.items[index].playcount++;
+ PlayList.player.jPlayer("setMedia", items[PlayList.current]);
+ items[index].playcount++;
PlayList.player.jPlayer("play",time);
if(index>0){
var previous=index-1;
}else{
- var previous=PlayList.items.length-1;
+ var previous=items.length-1;
}
- if(index+1<PlayList.items.length){
+ if(index+1<items.length){
var next=index+1;
}else{
var next=0;
}
- $('.jp-next').attr('title',PlayList.items[next].name);
- $('.jp-previous').attr('title',PlayList.items[previous].name);
+ $('.jp-next').attr('title',items[next].name);
+ $('.jp-previous').attr('title',items[previous].name);
if (typeof Collection !== 'undefined') {
Collection.registerPlay();
}
@@ -55,7 +60,7 @@ var PlayList={
}
}
}else{
- PlayList.init(PlayList.items[index].type,PlayList.play);
+ PlayList.init(items[index].type,PlayList.play);
}
}
},
@@ -95,28 +100,37 @@ var PlayList={
swfPath:OC.linkTo('media','js'),
});
},
- add:function(song){
+ add:function(song,temp,dontReset){
+ if(!dontReset){
+ PlayList.tempPlaylist=[];//clear the temp playlist
+ }
+ PlayList.isTemp=temp;
+ PlayList.isTemp=true;
if(!song){
return;
}
if(song.substr){//we are passed a string, asume it's a url to a song
- PlayList.addFile(song);
+ PlayList.addFile(song,temp,true);
}
if(song.albums){//a artist object was passed, add all albums inside it
$.each(song.albums,function(index,album){
- PlayList.add(album);
+ PlayList.add(album,temp,true);
});
}
if(song.songs){//a album object was passed, add all songs inside it
$.each(song.songs,function(index,song){
- PlayList.add(song);
+ PlayList.add(song,temp,true);
});
}
if(song.song_name){
var type=musicTypeFromFile(song.song_path);
var item={name:song.song_name,type:type,artist:song.artist_name,album:song.album_name,length:song.song_length,playcount:song.song_playcount};
item[type]=PlayList.urlBase+encodeURIComponent(song.song_path);
- PlayList.items.push(item);
+ if(PlayList.isTemp){
+ PlayList.tempPlaylist.push(item);
+ }else{
+ PlayList.items.push(item);
+ }
}
},
addFile:function(path){