You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

151 lines
5.3 KiB

#HTTP_HEADER{Content-Type: text/javascript}
#CACHE{24*3600,cache-client}
soundManager.setup({
url: '[(#CHEMIN{swf/soundmanager2.swf}|url_absolue|dirname)/]',
flashVersion: 9, // optional: shiny features (default = 8)
useFlashBlock: false, // optionally, enable when you're ready to dive in
debugMode: false
});
threeSixtyPlayer.config.scaleFont = (navigator.userAgent.match(/msie/i)?false:true);
threeSixtyPlayer.config.showHMSTime = true;
// enable some spectrum stuffs
threeSixtyPlayer.config.useWaveformData = true;
threeSixtyPlayer.config.useEQData = true;
// enable this in SM2 as well, as needed
if (threeSixtyPlayer.config.useWaveformData) {
soundManager.flash9Options.useWaveformData = true;
}
if (threeSixtyPlayer.config.useEQData) {
soundManager.flash9Options.useEQData = true;
}
if (threeSixtyPlayer.config.usePeakData) {
soundManager.flash9Options.usePeakData = true;
}
if (threeSixtyPlayer.config.useWaveformData || threeSixtyPlayer.flash9Options.useEQData || threeSixtyPlayer.flash9Options.usePeakData) {
// even if HTML5 supports MP3, prefer flash so the visualization features can be used.
soundManager.preferFlash = true;
}
$(document).ready(function(){
// classe audio et id timecode sur les liens vers #t123456789
$("a").each(function(){
var timecode = $(this)[0].href.match(/t(\d+)/) ;
if(typeof timecode !== "undefined" && timecode){
$(this).addClass("audio");
$(this).attr('id', timecode[0]);
}
});
// scroller vers le lien dans la page si timecode dans l'url d'arrivée #t10000
var tc = window.location.hash.match(/^#t(\d+)$/);
if(typeof tc !== "undefined" && tc){
tc = parseInt(tc[1]);
// trouver le lien avec ce timecode en href et y scroller
var lien = $('a.audio[href$="#t' + tc + '"]');
$("a.audio").removeClass("on");
lien.addClass("on");
$('body, html').animate({scrollTop: lien.offset().top - 70 }, 500);
}
// clic sur un lien avec timecode #t10000 ?
$("a.audio").on("click",function(){
// stopper un eventuel son en cours
if(Object.values(soundManager.sounds).length > 0){
Object.values(soundManager.sounds).forEach(function(e){
if(e.paused == false)
e.stop();
});
}
var timecode = $(this)[0].href.match(/t(\d+)/) ;
if(typeof timecode !== "undefined" && timecode){
timecode = timecode[1];
}
// démarrer le son du premier player
if(typeof timecode !== "undefined" && timecode){
$(".sm2-360btn").eq(0).click();
}
// décaler le en cours de timecode
var son = [] ;
Object.values(soundManager.sounds).forEach(function(e){
if(e.playState)
son = e ;
});
if(typeof timecode !== "undefined" && timecode && Object.values(soundManager.sounds).length > 0){
// son.from = timecode ;
// la valeur de from ci dessus n'est pas prise en compte, alors on décale le son
son.setPosition(timecode);
}
});
// surcharge des events play/pause etc : https://stackoverflow.com/questions/10127009/soundmanager2-onplay-event-configuration-does-not-work
var onplay360 = threeSixtyPlayer.events.play;
var myOnplay = function(){
// console.log("play de " + this.id);
// cas d'un clic utilisateur sur le player avec un #timecode dans l'url
if(Object.values(soundManager.sounds).length == 1){
var from = (window.location.hash).match(/t(\d+)/) ;
var son = Object.values(soundManager.sounds)[0] ;
if(typeof from !== "undefined" && from){
// on décale le son
son.setPosition(from[1]);
}
}
onplay360.apply(this); // forces the scope to 'this' = the sound object
};
threeSixtyPlayer.events.play = myOnplay;
var onpause360 = threeSixtyPlayer.events.pause;
var myOnpause = function(){
// console.log("pause de " + this.id);
onpause360.apply(this); // forces the scope to 'this' = the sound object
};
threeSixtyPlayer.events.pause = myOnpause;
var onresume360 = threeSixtyPlayer.events.resume;
var myOnresume = function(){
// console.log("resume de " + this.id);
onresume360.apply(this); // forces the scope to 'this' = the sound object
};
threeSixtyPlayer.events.resume = myOnresume;
var onfinish360 = threeSixtyPlayer.events.finish;
var myOnfinish = function(){
// console.log("finish de " + this.id);
onfinish360.apply(this); // forces the scope to 'this' = the sound object
};
threeSixtyPlayer.events.finish = myOnfinish;
var onstop360 = threeSixtyPlayer.events.stop;
var myStop = function(){
// console.log("arret de " + this.id);
onstop360.apply(this); // forces the scope to 'this' = the sound object
};
threeSixtyPlayer.events.stop = myStop;
var whileloading360 = threeSixtyPlayer.events.whileloading;
var mywhileloading = function(){
//console.log(this.id + ': loading ' + this.bytesLoaded + ' / ' + this.bytesTotal);
whileloading360.apply(this); // forces the scope to 'this' = the sound object
};
threeSixtyPlayer.events.whileloading = mywhileloading;
var onload360 = threeSixtyPlayer.events.onload;
var myonload = function(){
//console.log(this.id + ': loaded ' + this.bytesLoaded + ' / ' + this.bytesTotal);
onload360.apply(this); // forces the scope to 'this' = the sound object
};
threeSixtyPlayer.events.onload = myonload;
var whileplaying360 = threeSixtyPlayer.events.whileplaying;
var mywhileplaying = function(){
//console.log(this.id + ': loaded ' + this.position);
whileplaying360.apply(this); // forces the scope to 'this' = the sound object
};
threeSixtyPlayer.events.whileplaying = mywhileplaying;
});