properly save play/pause state of media player
This commit is contained in:
parent
f13ff8f601
commit
30ce4e5b6b
|
@ -19,7 +19,7 @@ var PlayList={
|
||||||
PlayList.play(next);
|
PlayList.play(next);
|
||||||
PlayList.render();
|
PlayList.render();
|
||||||
},
|
},
|
||||||
play:function(index){
|
play:function(index,ready){
|
||||||
if(index==null){
|
if(index==null){
|
||||||
index=PlayList.current;
|
index=PlayList.current;
|
||||||
}
|
}
|
||||||
|
@ -28,13 +28,12 @@ var PlayList={
|
||||||
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!=PlayList.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,PlayList.play);
|
PlayList.init(PlayList.items[index].type,function(){PlayList.play(null,ready)});
|
||||||
}else{
|
}else{
|
||||||
PlayList.player.jPlayer("setMedia", PlayList.items[PlayList.current]);
|
PlayList.player.jPlayer("setMedia", PlayList.items[PlayList.current]);
|
||||||
PlayList.items[index].playcount++;
|
PlayList.items[index].playcount++;
|
||||||
PlayList.player.jPlayer("play");
|
PlayList.player.jPlayer("play");
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_current',index);
|
localStorage.setItem(oc_current_user+'oc_playlist_current',index);
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_playing','true');
|
|
||||||
if(index>0){
|
if(index>0){
|
||||||
var previous=index-1;
|
var previous=index-1;
|
||||||
}else{
|
}else{
|
||||||
|
@ -50,6 +49,9 @@ var PlayList={
|
||||||
if (typeof Collection !== 'undefined') {
|
if (typeof Collection !== 'undefined') {
|
||||||
Collection.registerPlay();
|
Collection.registerPlay();
|
||||||
}
|
}
|
||||||
|
if(ready){
|
||||||
|
ready();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
PlayList.init(PlayList.items[index].type,PlayList.play);
|
PlayList.init(PlayList.items[index].type,PlayList.play);
|
||||||
|
@ -74,6 +76,12 @@ var PlayList={
|
||||||
}
|
}
|
||||||
$(PlayList.player).jPlayer({
|
$(PlayList.player).jPlayer({
|
||||||
ended:PlayList.next,
|
ended:PlayList.next,
|
||||||
|
pause:function(){
|
||||||
|
localStorage.setItem(oc_current_user+'oc_playlist_playing','false');
|
||||||
|
},
|
||||||
|
play:function(){
|
||||||
|
localStorage.setItem(oc_current_user+'oc_playlist_playing','true');
|
||||||
|
},
|
||||||
supplied:type,
|
supplied:type,
|
||||||
ready:function(){
|
ready:function(){
|
||||||
PlayList.load();
|
PlayList.load();
|
||||||
|
@ -145,6 +153,10 @@ var PlayList={
|
||||||
PlayList.current=parseInt((localStorage.getItem(oc_current_user+'oc_playlist_current')));
|
PlayList.current=parseInt((localStorage.getItem(oc_current_user+'oc_playlist_current')));
|
||||||
if(JSON.parse(localStorage.getItem(oc_current_user+'oc_playlist_playing'))){
|
if(JSON.parse(localStorage.getItem(oc_current_user+'oc_playlist_playing'))){
|
||||||
PlayList.play();
|
PlayList.play();
|
||||||
|
}else{
|
||||||
|
PlayList.play(null,function(){
|
||||||
|
PlayList.player.jPlayer("pause");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
PlayList.render();
|
PlayList.render();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue