prevent multiply owncloud instances on the same domain intefering with each others playlists
This commit is contained in:
parent
a883fcca3c
commit
15ea83834d
|
@ -52,10 +52,8 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
var oc_current_user=OC.currentUser;
|
var oc_current_user=OC.currentUser;
|
||||||
if(typeof PlayList==='undefined'){
|
if(typeof PlayList==='undefined'){
|
||||||
if(typeof localStorage !== 'undefined' && localStorage){
|
if(OC.localStorage.getItem('playlist_items') && OC.localStorage.getItem('playlist_items').length && OC.localStorage.getItem('playlist_active')!=true){
|
||||||
if(localStorage.getItem(oc_current_user+'oc_playlist_items') && localStorage.getItem(oc_current_user+'oc_playlist_items')!='[]' && localStorage.getItem(oc_current_user+'oc_playlist_active')!='true'){
|
|
||||||
loadPlayer();
|
loadPlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
|
@ -34,7 +34,7 @@ var PlayList={
|
||||||
if(PlayList.player){
|
if(PlayList.player){
|
||||||
if(PlayList.player.data('jPlayer').options.supplied!=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("play",time);
|
PlayList.player.jPlayer("play",time);
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
|
OC.localStorage.setItem('playlist_time',time);
|
||||||
PlayList.player.jPlayer("destroy");
|
PlayList.player.jPlayer("destroy");
|
||||||
// PlayList.save(); // so that the init don't lose the playlist
|
// PlayList.save(); // so that the init don't lose the playlist
|
||||||
PlayList.init(items[index].type,null); // init calls load that calls play
|
PlayList.init(items[index].type,null); // init calls load that calls play
|
||||||
|
@ -64,9 +64,8 @@ var PlayList={
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
|
OC.localStorage.setItem('playlist_time',time);
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_playing','true');
|
OC.localStorage.setItem('playlist_playing',true);
|
||||||
// PlayList.save(); // so that the init don't lose the playlist
|
|
||||||
PlayList.init(items[index].type,null); // init calls load that calls play
|
PlayList.init(items[index].type,null); // init calls load that calls play
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,11 +91,11 @@ var PlayList={
|
||||||
$(PlayList.player).jPlayer({
|
$(PlayList.player).jPlayer({
|
||||||
ended:PlayList.next,
|
ended:PlayList.next,
|
||||||
pause:function(){
|
pause:function(){
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_playing','false');
|
OC.localStorage.setItem('playlist_playing',false);
|
||||||
document.title = "ownCloud";
|
document.title = "ownCloud";
|
||||||
},
|
},
|
||||||
play:function(event){
|
play:function(event){
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_playing','true');
|
OC.localStorage.setItem('playlist_playing',true);
|
||||||
document.title = "\u25b8 " + event.jPlayer.status.media.name + " - " + event.jPlayer.status.media.artist + " - ownCloud";
|
document.title = "\u25b8 " + event.jPlayer.status.media.name + " - " + event.jPlayer.status.media.artist + " - ownCloud";
|
||||||
},
|
},
|
||||||
supplied:type,
|
supplied:type,
|
||||||
|
@ -161,38 +160,35 @@ var PlayList={
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
save:function(){
|
save:function(){
|
||||||
if(typeof localStorage !== 'undefined' && localStorage){
|
OC.localStorage.setItem('playlist_items',PlayList.items);
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_items',JSON.stringify(PlayList.items));
|
OC.localStorage.setItem('playlist_current',PlayList.current);
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_current',PlayList.current);
|
|
||||||
if(PlayList.player) {
|
if(PlayList.player) {
|
||||||
if(PlayList.player.data('jPlayer')) {
|
if(PlayList.player.data('jPlayer')) {
|
||||||
var time=Math.round(PlayList.player.data('jPlayer').status.currentTime);
|
var time=Math.round(PlayList.player.data('jPlayer').status.currentTime);
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
|
OC.localStorage.setItem('playlist_time',time);
|
||||||
var volume=PlayList.player.data('jPlayer').options.volume*100;
|
var volume=PlayList.player.data('jPlayer').options.volume*100;
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_volume',volume);
|
OC.localStorage.setItem('playlist_volume',volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_active','true');
|
OC.localStorage.setItem('playlist_active',true);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
load:function(){
|
load:function(){
|
||||||
if(typeof localStorage !== 'undefined' && localStorage){
|
|
||||||
PlayList.active=true;
|
PlayList.active=true;
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_active','true');
|
OC.localStorage.setItem('playlist_active',true);
|
||||||
if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_items')){
|
if(OC.localStorage.hasItem('playlist_items')){
|
||||||
PlayList.items=JSON.parse(localStorage.getItem(oc_current_user+'oc_playlist_items'));
|
PlayList.items=OC.localStorage.getItem('playlist_items');
|
||||||
if(PlayList.items.length>0){
|
if(PlayList.items && PlayList.items.length>0){
|
||||||
PlayList.current=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_current'));
|
PlayList.current=OC.localStorage.getItem('playlist_current');
|
||||||
var time=parseInt(localStorage.getItem(oc_current_user+'oc_playlist_time'));
|
var time=OC.localStorage.getItem('playlist_time');
|
||||||
if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_volume')){
|
if(OC.localStorage.hasItem('playlist_volume')){
|
||||||
var volume=localStorage.getItem(oc_current_user+'oc_playlist_volume');
|
var volume=OC.localStorage.getItem('playlist_volume');
|
||||||
PlayList.volume=volume/100;
|
PlayList.volume=volume/100;
|
||||||
$('.jp-volume-bar-value').css('width',volume+'%');
|
$('.jp-volume-bar-value').css('width',volume+'%');
|
||||||
if(PlayList.player.data('jPlayer')){
|
if(PlayList.player.data('jPlayer')){
|
||||||
PlayList.player.jPlayer("option",'volume',volume/100);
|
PlayList.player.jPlayer("option",'volume',volume/100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(JSON.parse(localStorage.getItem(oc_current_user+'oc_playlist_playing'))){
|
if(OC.localStorage.getItem('playlist_playing')){
|
||||||
PlayList.play(null,time);
|
PlayList.play(null,time);
|
||||||
}else{
|
}else{
|
||||||
PlayList.play(null,time,function(){
|
PlayList.play(null,time,function(){
|
||||||
|
@ -204,13 +200,12 @@ var PlayList={
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$(window).bind('beforeunload', function (){
|
$(window).bind('beforeunload', function (){
|
||||||
PlayList.save();
|
PlayList.save();
|
||||||
if(PlayList.active){
|
if(PlayList.active){
|
||||||
localStorage.setItem(oc_current_user+'oc_playlist_active','false');
|
OC.localStorage.setItem('playlist_active',false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue