mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 09:42:09 -04:00
fix persistent playlist for media player
This commit is contained in:
parent
c39c6d36df
commit
1639a1ca49
7 changed files with 65 additions and 26 deletions
19
apps/media/css/player.css
Normal file
19
apps/media/css/player.css
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#playercontrols{
|
||||
display:inline;
|
||||
width:7em;
|
||||
height:1em;
|
||||
position:fixed;
|
||||
top:auto;
|
||||
left:auto;
|
||||
background:transparent;
|
||||
box-shadow:none;
|
||||
-webkit-box-shadow:none;
|
||||
}
|
||||
#playercontrols li{
|
||||
float:left;
|
||||
}
|
||||
#playercontrols a, #playercontrols li{
|
||||
margin:0px;
|
||||
padding:0;
|
||||
left:0;
|
||||
}
|
||||
|
|
@ -22,16 +22,17 @@ function addAudio(filename){
|
|||
|
||||
function loadPlayer(type,ready){
|
||||
if(!loadPlayer.done){
|
||||
loadPlayer.done=true;
|
||||
OC.addStyle('media','player');
|
||||
OC.addScript('media','jquery.jplayer.min',function(){
|
||||
OC.addScript('media','player',function(){
|
||||
$('body').append($('<div id="playerPlaceholder"/>'))
|
||||
$('#playerPlaceholder').append($('<div/>')).load(OC.filePath('media','templates','player.php'),function(){
|
||||
loadPlayer.done=true;
|
||||
var navItem=$('#apps a[href="'+OC.linkTo('media','index.php')+'"]');
|
||||
navItem.height(navItem.height());
|
||||
navItem.load(OC.filePath('media','templates','player.php'),function(){
|
||||
PlayList.init(type,ready);
|
||||
});
|
||||
});
|
||||
});
|
||||
OC.addStyle('media','player');
|
||||
}else{
|
||||
ready();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,18 +28,19 @@ var PlayList={
|
|||
if(index==null){
|
||||
index=PlayList.current;
|
||||
}
|
||||
PlayList.save();
|
||||
if(index>-1 && index<items.length){
|
||||
PlayList.current=index;
|
||||
if(PlayList.player){
|
||||
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);
|
||||
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
|
||||
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
|
||||
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
|
||||
}else{
|
||||
PlayList.player.jPlayer("setMedia", items[PlayList.current]);
|
||||
$(".jp-current-song").text(items[PlayList.current].name);
|
||||
$(".jp-current-song").text(items[PlayList.current].name);
|
||||
items[index].playcount++;
|
||||
PlayList.player.jPlayer("play",time);
|
||||
if(index>0){
|
||||
|
|
@ -57,6 +58,7 @@ var PlayList={
|
|||
if (typeof Collection !== 'undefined') {
|
||||
Collection.registerPlay();
|
||||
}
|
||||
PlayList.render();
|
||||
if(ready){
|
||||
ready();
|
||||
}
|
||||
|
|
@ -64,12 +66,12 @@ var PlayList={
|
|||
}else{
|
||||
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
|
||||
localStorage.setItem(oc_current_user+'oc_playlist_playing','true');
|
||||
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
|
||||
}
|
||||
}
|
||||
$(".song").removeClass("collection_playing");
|
||||
$(".jp-playlist-" + index).addClass("collection_playing");
|
||||
$(".song").removeClass("collection_playing");
|
||||
$(".jp-playlist-" + index).addClass("collection_playing");
|
||||
},
|
||||
init:function(type,ready){
|
||||
if(!PlayList.player){
|
||||
|
|
@ -85,7 +87,7 @@ var PlayList={
|
|||
PlayList.render();
|
||||
return false;
|
||||
});
|
||||
PlayList.player=$('#controls div.player');
|
||||
PlayList.player=$('#jp-player');
|
||||
}
|
||||
$(PlayList.player).jPlayer({
|
||||
ended:PlayList.next,
|
||||
|
|
@ -103,7 +105,7 @@ var PlayList={
|
|||
}
|
||||
},
|
||||
volume:PlayList.volume,
|
||||
cssSelectorAncestor:'#controls',
|
||||
cssSelectorAncestor:'.player-controls',
|
||||
swfPath:OC.linkTo('media','js'),
|
||||
});
|
||||
},
|
||||
|
|
@ -130,7 +132,7 @@ var PlayList={
|
|||
var type=musicTypeFromFile(song.path);
|
||||
var item={name:song.name,type:type,artist:song.artist,album:song.album,length:song.length,playcount:song.playCount};
|
||||
item[type]=PlayList.urlBase+encodeURIComponent(song.path);
|
||||
PlayList.items.push(item);
|
||||
PlayList.items.push(item);
|
||||
}
|
||||
},
|
||||
addFile:function(path){
|
||||
|
|
@ -160,14 +162,14 @@ var PlayList={
|
|||
if(typeof localStorage !== 'undefined' && localStorage){
|
||||
localStorage.setItem(oc_current_user+'oc_playlist_items',JSON.stringify(PlayList.items));
|
||||
localStorage.setItem(oc_current_user+'oc_playlist_current',PlayList.current);
|
||||
if(PlayList.player) {
|
||||
if(PlayList.player.data('jPlayer')) {
|
||||
var time=Math.round(PlayList.player.data('jPlayer').status.currentTime);
|
||||
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
|
||||
var volume=PlayList.player.data('jPlayer').options.volume*100;
|
||||
localStorage.setItem(oc_current_user+'oc_playlist_volume',volume);
|
||||
}
|
||||
}
|
||||
if(PlayList.player) {
|
||||
if(PlayList.player.data('jPlayer')) {
|
||||
var time=Math.round(PlayList.player.data('jPlayer').status.currentTime);
|
||||
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
|
||||
var volume=PlayList.player.data('jPlayer').options.volume*100;
|
||||
localStorage.setItem(oc_current_user+'oc_playlist_volume',volume);
|
||||
}
|
||||
}
|
||||
if(PlayList.active){
|
||||
localStorage.setItem(oc_current_user+'oc_playlist_active','false');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ PlayList.hide=function(){
|
|||
|
||||
$(document).ready(function(){
|
||||
PlayList.parent=$('#leftcontent');
|
||||
PlayList.init();
|
||||
$('#selectAll').click(function(){
|
||||
if($(this).attr('checked')){
|
||||
// Check all
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<div id="controls">
|
||||
<div class='player-controls' id="controls">
|
||||
<ul class="jp-controls">
|
||||
<li><a href="#" class="jp-play action"><img class="svg" alt="<?php echo $l->t('Play');?>" src="<?php echo image_path('core', 'actions/play-big.svg'); ?>" /></a></li>
|
||||
<li><a href="#" class="jp-pause action"><img class="svg" alt="<?php echo $l->t('Pause');?>" src="<?php echo image_path('core', 'actions/pause-big.svg'); ?>" /></a></li>
|
||||
|
|
|
|||
16
apps/media/templates/player.php
Normal file
16
apps/media/templates/player.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
if(!isset($_)){//allow the template to be loaded standalone
|
||||
require_once '../../../lib/base.php';
|
||||
$tmpl = new OC_Template( 'media', 'player');
|
||||
$tmpl->printPage();
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<div class='player-controls' id="playercontrols">
|
||||
<div class="player" id="jp-player"></div>
|
||||
<ul class="jp-controls">
|
||||
<li><a href="#" class="jp-play action"><img class="svg" alt="<?php echo $l->t('Play');?>" src="<?php echo image_path('core', 'actions/play.svg'); ?>" /></a></li>
|
||||
<li><a href="#" class="jp-pause action"><img class="svg" alt="<?php echo $l->t('Pause');?>" src="<?php echo image_path('core', 'actions/pause.svg'); ?>" /></a></li>
|
||||
<li><a href="#" class="jp-next action"><img class="svg" alt="<?php echo $l->t('Next');?>" src="<?php echo image_path('core', 'actions/play-next.svg'); ?>" /></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
@ -53,7 +53,7 @@ FileActions={
|
|||
},
|
||||
display:function(parent){
|
||||
FileActions.currentFile=parent;
|
||||
$('.action').remove();
|
||||
$('#fileList .action').remove();
|
||||
var actions=FileActions.get(FileActions.getCurrentMimeType(),FileActions.getCurrentType());
|
||||
var file=FileActions.getCurrentFile();
|
||||
if($('tr[data-file="'+file+'"]').data('renaming')){
|
||||
|
|
@ -104,12 +104,12 @@ FileActions={
|
|||
});
|
||||
parent.parent().children().last().append(element);
|
||||
}
|
||||
$('.action').hide();
|
||||
$('.action').fadeIn(200);
|
||||
$('#fileList .action').hide();
|
||||
$('#fileList .action').fadeIn(200);
|
||||
return false;
|
||||
},
|
||||
hide:function(){
|
||||
$('.action').fadeOut(200,function(){
|
||||
$('#fileList .action').fadeOut(200,function(){
|
||||
$(this).remove();
|
||||
});
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue