2011-07-26 18:04:57 +04:00
|
|
|
function musicTypeFromFile(file){
|
|
|
|
var extention=file.substr(file.indexOf('.')+1);
|
|
|
|
if(extention=='ogg'){
|
|
|
|
return 'oga'
|
|
|
|
}
|
|
|
|
//TODO check for more specific cases
|
|
|
|
return extention;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-29 00:20:26 +04:00
|
|
|
loadPlayer.done=true;
|
|
|
|
OC.addStyle('media','player');
|
2011-07-26 18:04:57 +04:00
|
|
|
OC.addScript('media','jquery.jplayer.min',function(){
|
|
|
|
OC.addScript('media','player',function(){
|
2011-09-29 00:20:26 +04: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 18:04:57 +04:00
|
|
|
PlayList.init(type,ready);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
ready();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
loadPlayer.done=false
|
|
|
|
|
2011-07-28 06:29:04 +04:00
|
|
|
// FileActions.register('audio','Add to playlist','',addAudio);
|
|
|
|
// FileActions.register('application/ogg','Add to playlist','',addAudio);
|
2011-07-26 18:04:57 +04:00
|
|
|
|
2011-08-01 03:20:00 +04: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 18:53:00 +04:00
|
|
|
var oc_current_user=OC.currentUser;
|
2011-08-01 03:21:50 +04:00
|
|
|
if(typeof PlayList==='undefined'){
|
2012-01-15 22:25:55 +04:00
|
|
|
if(OC.localStorage.getItem('playlist_items') && OC.localStorage.getItem('playlist_items').length && OC.localStorage.getItem('playlist_active')!=true){
|
|
|
|
loadPlayer();
|
2011-08-01 03:12:28 +04:00
|
|
|
}
|
|
|
|
}
|
2011-07-26 18:04:57 +04:00
|
|
|
});
|