var audioPlaylist; var URLBASE='ajax/api.php?action=play&path='; $(document).ready(function() { if(typeof FileActions!=='undefined'){ URLBASE='../apps/media/ajax/api.php?action=play&path='; var playerLoaded=false; function playFile(filename){ audioPlaylist.playlist=[]; audioPlaylist.addToPlaylist({ song_name:filename, song_path:$('#dir').val()+'/'+filename },true); audioPlaylist.playlistChange(audioPlaylist.playlist.length-1); } function playAudio(filename){ if(!playerLoaded){ var parent=$('body').append('
'); $('#media_container').load('../apps/media/templates/music.php',function(){ playerLoaded=true; //remove playlist and collection view $('#jp_playlist_1').remove(); $('collection').remove(); //init the audio player audioPlaylist =initPlayList(false,false,function(){ //play the file playFile(filename); }); }); }else{ playFile(filename); } } FileActions.register('audio','Play',playAudio); FileActions.register('application/ogg','Play',playAudio); FileActions.setDefault('audio','Play'); FileActions.setDefault('application/ogg','Play'); } Playlist = function(instance, playlist, options) { var self = this; this.instance = instance; // String: To associate specific HTML with this playlist this.playlist = playlist; // Array of Objects: The playlist this.options = options; // Object: The jPlayer constructor options for this playlist this.current = -1; this.cssId = { jPlayer: "jplayer_", interface: "jp_interface_", playlist: "jp_playlist_" }; this.cssSelector = {}; $.each(this.cssId, function(entity, id) { self.cssSelector[entity] = "#" + id + self.instance; }); if(!this.options.cssSelectorAncestor) { this.options.cssSelectorAncestor = this.cssSelector.interface; } $(this.cssSelector.jPlayer).jPlayer(this.options); $(this.cssSelector.interface + " .jp-previous").click(function() { self.playlistPrev(); $(this).blur(); return false; }); $(this.cssSelector.interface + " .jp-next").click(function() { self.playlistNext(); $(this).blur(); return false; }); }; Playlist.prototype = { displayPlaylist: function() { var self = this; $(this.cssSelector.playlist + " ul").empty(); for (i=0; i < this.playlist.length; i++) { var listItem = (i === this.playlist.length-1) ? "