2011-07-26 14:04:57 +00:00
|
|
|
function musicTypeFromFile(file){
|
2012-04-15 11:32:45 +00:00
|
|
|
var extension=file.substr(file.indexOf('.')+1).toLowerCase();
|
|
|
|
if(extension=='ogg'){
|
2012-02-21 21:31:35 +00:00
|
|
|
return 'oga';
|
2011-07-26 14:04:57 +00:00
|
|
|
}
|
|
|
|
//TODO check for more specific cases
|
2012-04-15 11:32:45 +00:00
|
|
|
return extension;
|
2011-07-26 14:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function playAudio(filename){
|
|
|
|
loadPlayer(musicTypeFromFile(filename),function(){
|
|
|
|
PlayList.add($('#dir').val()+'/'+filename);
|
|
|
|
PlayList.play(PlayList.items.length-1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function addAudio(filename){
|
|
|
|
loadPlayer(musicTypeFromFile(filename),function(){
|
|
|
|
PlayList.add($('#dir').val()+'/'+filename);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadPlayer(type,ready){
|
|
|
|
if(!loadPlayer.done){
|
2011-09-28 20:20:26 +00:00
|
|
|
loadPlayer.done=true;
|
|
|
|
OC.addStyle('media','player');
|
2011-07-26 14:04:57 +00:00
|
|
|
OC.addScript('media','jquery.jplayer.min',function(){
|
|
|
|
OC.addScript('media','player',function(){
|
2011-09-28 20:20:26 +00:00
|
|
|
var navItem=$('#apps a[href="'+OC.linkTo('media','index.php')+'"]');
|
|
|
|
navItem.height(navItem.height());
|
|
|
|
navItem.load(OC.filePath('media','templates','player.php'),function(){
|
2011-07-26 14:04:57 +00:00
|
|
|
PlayList.init(type,ready);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
ready();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
2012-02-21 21:31:35 +00:00
|
|
|
loadPlayer.done=false;
|
2011-07-26 14:04:57 +00:00
|
|
|
|
2011-07-28 02:29:04 +00:00
|
|
|
// FileActions.register('audio','Add to playlist','',addAudio);
|
|
|
|
// FileActions.register('application/ogg','Add to playlist','',addAudio);
|
2011-07-26 14:04:57 +00:00
|
|
|
|
2011-07-31 23:20:00 +00:00
|
|
|
if(typeof FileActions!=='undefined'){
|
|
|
|
FileActions.register('audio','Play','',playAudio);
|
|
|
|
FileActions.register('application/ogg','','Play',playAudio);
|
|
|
|
FileActions.setDefault('audio','Play');
|
|
|
|
FileActions.setDefault('application/ogg','Play');
|
|
|
|
}
|
2011-08-11 14:53:00 +00:00
|
|
|
var oc_current_user=OC.currentUser;
|
2011-07-31 23:21:50 +00:00
|
|
|
if(typeof PlayList==='undefined'){
|
2012-01-15 18:25:55 +00:00
|
|
|
if(OC.localStorage.getItem('playlist_items') && OC.localStorage.getItem('playlist_items').length && OC.localStorage.getItem('playlist_active')!=true){
|
|
|
|
loadPlayer();
|
2011-07-31 23:12:28 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-23 14:11:03 +00:00
|
|
|
});
|