partly fix media player
This commit is contained in:
parent
0b4ed25776
commit
5a26640f63
|
@ -60,14 +60,14 @@ Collection={
|
||||||
tr.find('td.title a').text(song.song_name);
|
tr.find('td.title a').text(song.song_name);
|
||||||
tr.find('td.title a').click(function(event){
|
tr.find('td.title a').click(function(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
PlayList.add(song);
|
PlayList.add(song,true);
|
||||||
PlayList.render();
|
PlayList.play(0);
|
||||||
});
|
});
|
||||||
if(artist.artist_name!=lastArtist){
|
if(artist.artist_name!=lastArtist){
|
||||||
tr.find('td.artist a').click(function(event){
|
tr.find('td.artist a').click(function(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
PlayList.add(artist);
|
PlayList.add(artist,true);
|
||||||
PlayList.render();
|
PlayList.play(0);
|
||||||
});
|
});
|
||||||
tr.find('td.artist a').text(artist.artist_name);
|
tr.find('td.artist a').text(artist.artist_name);
|
||||||
if(artist.albums.length>1){
|
if(artist.albums.length>1){
|
||||||
|
@ -87,8 +87,8 @@ Collection={
|
||||||
if(album.album_name!=lastAlbum){
|
if(album.album_name!=lastAlbum){
|
||||||
tr.find('td.album a').click(function(event){
|
tr.find('td.album a').click(function(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
PlayList.add(album);
|
PlayList.add(album,true);
|
||||||
PlayList.render();
|
PlayList.play(0);
|
||||||
});
|
});
|
||||||
tr.find('td.album a').text(album.album_name);
|
tr.find('td.album a').text(album.album_name);
|
||||||
if(album.songs.length>1){
|
if(album.songs.length>1){
|
||||||
|
|
|
@ -5,48 +5,53 @@ var PlayList={
|
||||||
player:null,
|
player:null,
|
||||||
volume:0.8,
|
volume:0.8,
|
||||||
active:false,
|
active:false,
|
||||||
|
tempPlaylist:[],
|
||||||
|
isTemp:true,
|
||||||
next:function(){
|
next:function(){
|
||||||
|
var items=(PlayList.isTemp)?PlayList.tempPlaylist:PlayList.items;
|
||||||
var next=PlayList.current+1;
|
var next=PlayList.current+1;
|
||||||
if(next>=PlayList.items.length){
|
if(next>=items.length){
|
||||||
next=0;
|
next=0;
|
||||||
}
|
}
|
||||||
PlayList.play(next);
|
PlayList.play(next);
|
||||||
PlayList.render();
|
PlayList.render();
|
||||||
},
|
},
|
||||||
previous:function(){
|
previous:function(){
|
||||||
|
var items=(PlayList.isTemp)?PlayList.tempPlaylist:PlayList.items;
|
||||||
var next=PlayList.current-1;
|
var next=PlayList.current-1;
|
||||||
if(next<0){
|
if(next<0){
|
||||||
next=PlayList.items.length-1;
|
next=items.length-1;
|
||||||
}
|
}
|
||||||
PlayList.play(next);
|
PlayList.play(next);
|
||||||
PlayList.render();
|
PlayList.render();
|
||||||
},
|
},
|
||||||
play:function(index,time,ready){
|
play:function(index,time,ready){
|
||||||
|
var items=(PlayList.isTemp)?PlayList.tempPlaylist:PlayList.items;
|
||||||
if(index==null){
|
if(index==null){
|
||||||
index=PlayList.current;
|
index=PlayList.current;
|
||||||
}
|
}
|
||||||
if(index>-1 && index<PlayList.items.length){
|
if(index>-1 && index<items.length){
|
||||||
PlayList.current=index;
|
PlayList.current=index;
|
||||||
if(PlayList.player){
|
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.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{
|
}else{
|
||||||
PlayList.player.jPlayer("setMedia", PlayList.items[PlayList.current]);
|
PlayList.player.jPlayer("setMedia", items[PlayList.current]);
|
||||||
PlayList.items[index].playcount++;
|
items[index].playcount++;
|
||||||
PlayList.player.jPlayer("play",time);
|
PlayList.player.jPlayer("play",time);
|
||||||
if(index>0){
|
if(index>0){
|
||||||
var previous=index-1;
|
var previous=index-1;
|
||||||
}else{
|
}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;
|
var next=index+1;
|
||||||
}else{
|
}else{
|
||||||
var next=0;
|
var next=0;
|
||||||
}
|
}
|
||||||
$('.jp-next').attr('title',PlayList.items[next].name);
|
$('.jp-next').attr('title',items[next].name);
|
||||||
$('.jp-previous').attr('title',PlayList.items[previous].name);
|
$('.jp-previous').attr('title',items[previous].name);
|
||||||
if (typeof Collection !== 'undefined') {
|
if (typeof Collection !== 'undefined') {
|
||||||
Collection.registerPlay();
|
Collection.registerPlay();
|
||||||
}
|
}
|
||||||
|
@ -55,7 +60,7 @@ var PlayList={
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
PlayList.init(PlayList.items[index].type,PlayList.play);
|
PlayList.init(items[index].type,PlayList.play);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -95,29 +100,38 @@ var PlayList={
|
||||||
swfPath:OC.linkTo('media','js'),
|
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){
|
if(!song){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(song.substr){//we are passed a string, asume it's a url to a song
|
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
|
if(song.albums){//a artist object was passed, add all albums inside it
|
||||||
$.each(song.albums,function(index,album){
|
$.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
|
if(song.songs){//a album object was passed, add all songs inside it
|
||||||
$.each(song.songs,function(index,song){
|
$.each(song.songs,function(index,song){
|
||||||
PlayList.add(song);
|
PlayList.add(song,temp,true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(song.song_name){
|
if(song.song_name){
|
||||||
var type=musicTypeFromFile(song.song_path);
|
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};
|
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);
|
item[type]=PlayList.urlBase+encodeURIComponent(song.song_path);
|
||||||
|
if(PlayList.isTemp){
|
||||||
|
PlayList.tempPlaylist.push(item);
|
||||||
|
}else{
|
||||||
PlayList.items.push(item);
|
PlayList.items.push(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
addFile:function(path){
|
addFile:function(path){
|
||||||
var type=musicTypeFromFile(path);
|
var type=musicTypeFromFile(path);
|
||||||
|
|
Loading…
Reference in New Issue