- return FOUND;
-}
-
-function play_next_source(){
- var FOUND = false;
- if(current_document != false){
- if($("#document_" + current_document).size()){
- var current_source_document_id = $("#document_" + current_document).attr("id");
- var current_source_id = get_current_source_id();
- if(current_source_id != false){
- var CURRENT_FOUND = false;
- $(".track").not(".pistes .track").not(".derivation .track").each(
- function(){
- if(!FOUND){
- if(CURRENT_FOUND){
- $(this).find(".documents li").not(".pistes .documents li").not(".derivation .documents li").each(
- function(){
- if(!FOUND){
- var source_document_id = $(this).attr("id").substring(9);
- if(source_document_id.length > 0){
- if($("#player_" + source_document_id).size()){
- FOUND = true;
- play(source_document_id);
- }
- }
- }
- }
- );
- }
- else{
- if(current_source_id == $(this).attr("id").substring("6")){
- CURRENT_FOUND = true;
- }
- }
- }
- }
- );
- }
- }
- }
- return FOUND;
-}
-
-function play(id_document){
- if(current_document == id_document){
- if($("#audio_" + current_document).get(0).paused){
- gui_state("playing");
- $("#audio_" + current_document).get(0).play();
- }
- }
- else{
- if(current_document != false){
- var audio_elt = $("#audio_" + current_document).get(0);
- audio_elt.pause();
- audio_elt.currentTime = 0;
- gui_state("stoped");
- }
- current_document = id_document;
- _play(0);
- }
-}
-
-function play_source_from(id_source, position){
- if(
- (current_document != false)
- && (current_source_id = get_current_source_id())
- && (id_source == current_source_id)
- ){
- _play(position);
- }
- else{
- stop();
- var FOUND = false;
- $("#track_" + id_source + " .documents li").each(
- function(){
- if(!FOUND){
- var source_document_id = $(this).attr("id").substring(9);
- if(source_document_id.length > 0){
- if($("#player_" + source_document_id).size()){
- FOUND = true;
- current_document = source_document_id;
- _play(position);
- }
- }
- }
- }
- );
- }
-}
-
-function _play(position){
- if(current_document != false){
- var audio_elt = $("#audio_" + current_document).get(0);
- audio_elt.preload = "auto";
- audio_elt.addEventListener("loadeddata", track_loadeddata, false);
- audio_elt.addEventListener("canplaythrough", track_canplaythrough, false);
- audio_elt.addEventListener("playing", track_playing, false);
- gui_state("loading");
- audio_elt.position = position;
- audio_elt.load();
- }
-}
-
-function track_loadeddata(event){
- var audio_elt = event.target;
- audio_elt.removeEventListener("loadeddata", track_loadeddata, false);
- if(current_document != false){
- audio_elt.currentTime = audio_elt.position ? (audio_elt.position * audio_elt.duration) / 100 : 0;
- }
-}
-
-function track_canplaythrough(event){
- var audio_elt = event.target;
- audio_elt.removeEventListener("canplaythrough", track_canplaythrough, false);
- audio_elt.play();