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){
|
|
|
|
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;
|
|
|
|
PlayList.init(type,ready);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
OC.addStyle('media','player');
|
|
|
|
}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'){
|
2011-08-05 18:05:10 +04:00
|
|
|
if(typeof localStorage !== 'undefined' && localStorage){
|
2011-08-04 03:19:21 +04:00
|
|
|
if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_items') && localStorage.getItem(oc_current_user+'oc_playlist_items')!='[]' && localStorage.getItem(oc_current_user+'oc_playlist_active')!='true'){
|
2011-08-01 03:21:50 +04:00
|
|
|
loadPlayer();
|
|
|
|
}
|
2011-08-01 03:12:28 +04:00
|
|
|
}
|
|
|
|
}
|
2011-07-26 18:04:57 +04:00
|
|
|
});
|