Browse Source

Mieux nommer les fonctions, bien changer les play/pause meme en cas de play sur un autre payer alors qu'on en a un en pause, recharger les sons nouveaux après un onAjaxload

master
BoOz 2 months ago
parent
commit
fe58f15cf7
  1. 2
      paquet.xml
  2. 2
      plugin.xml
  3. 42
      soundmanager.js.html

2
paquet.xml

@ -1,7 +1,7 @@
<paquet
prefix="sm"
categorie="multimedia"
version="2.1.2"
version="2.1.3"
etat="stable"
compatibilite="[2.0.0;3.3.*]"
logo="skins/soundmanager.png"

2
plugin.xml

@ -6,7 +6,7 @@
</multi>
</nom>
<auteur>BoOz</auteur>
<version>2.1.2</version>
<version>2.1.3</version>
<etat>stable</etat>
<prefix>sm</prefix>
<icon>skins/soundmanager.png</icon>

42
soundmanager.js.html

@ -15,12 +15,13 @@ $(document).ready(function(){
// Ready to use; soundManager.createSound() etc. can now be called.
lastSound = {} ;
sound_manager_init();
//onAjaxLoad(sound_manager_init);
onAjaxLoad(sound_manager_init);
}
});
});
function sound_manager_init(){
// console.log("init");
// indexer les liens mp3 et ogg
$("a[rel='enclosure'][href*='.mp3'],a[rel='enclosure'][href*='.ogg']").each(function(i){
$(this).attr('data-soundId',i);
@ -31,6 +32,8 @@ function sound_manager_init(){
// animation des boutons
$(".play")
.not('.active')
.addClass('active') // marquer les player déjà traités (deuxieme appel ajax possible ensuite).
.html("<span class='ui-icon-play'>play</span>")
.unbind('click')
.click( function(e) {
@ -49,7 +52,9 @@ function sound_manager_init(){
jouer_son(media_id, media_url);
});
$(".stop").click(function() {
$(".stop")
.unbind('click')
.click(function() {
soundManager.stopAll();
$(".position").width(0);
});
@ -73,15 +78,15 @@ function jouer_son(media_id, media_url){
if (thisSound == lastSound) {
// and was playing (or paused)
thisSound.togglePause();
} else {
// different sound
thisSound.togglePause(); // start playing current
} else { // different sound
if (lastSound) {
//console.log("on arrete déjà chargé ", lastSound.sID)
soundManager.stop(lastSound.sID);
soundManager.unload(lastSound.sID);
lastSound = thisSound ;
}
// play
thisSound.togglePause(); // start playing current
}
} else {
// create sound
@ -92,19 +97,22 @@ function jouer_son(media_id, media_url){
autoPlay: false,
autoLoad: true,
onplay:function(){
maj_bouton_play_pause(soundId);
//console.log("play");
alterner_bouton_play_pause(soundId);
if(typeof(myOnPlay) === "function"){
myOnPlay();
}
},
onpause:function(){
maj_bouton_play_pause(soundId);
//console.log("pause");
alterner_bouton_play_pause(soundId);
if(typeof(myOnPause) === "function"){
myOnPause();
}
},
onresume:function(){
maj_bouton_play_pause(soundId);
//console.log("resume");
alterner_bouton_play_pause(soundId);
if(typeof(myOnResume) === "function"){
myOnResume();
}
@ -134,7 +142,8 @@ function jouer_son(media_id, media_url){
}
},
onfinish:function(){
maj_bouton_play_pause(soundId);
//console.log("finish");
alterner_bouton_play_pause(soundId);
if(typeof(myOnFinish) === "function"){
myOnFinish();
}
@ -142,7 +151,8 @@ function jouer_son(media_id, media_url){
next_sound_parent.find(".play").trigger("click");
},
onstop:function(){
maj_bouton_play_pause(soundId);
//console.log("stop");
reinitialiser_bouton_play_pause(soundId);
$(".position").width(0);
if(typeof(myOnStop) === "function"){
myOnStop();
@ -152,7 +162,7 @@ function jouer_son(media_id, media_url){
// stop last sound
if (lastSound) {
//console.log("on arrete", lastSound.sID);
//console.log("on arrete " + lastSound.sID + "au chargement de " + soundId);
soundManager.stop(lastSound.sID);
soundManager.unload(lastSound.sID);
}
@ -186,7 +196,7 @@ function jouer_son(media_id, media_url){
}
}
function maj_bouton_play_pause(media_id){
function alterner_bouton_play_pause(media_id){
var that = $("." + media_id + " .play") ;
if (that.text() === "play") {
that.html("<span class='ui-icon-pause'>pause</span>")
@ -196,3 +206,9 @@ function maj_bouton_play_pause(media_id){
.attr("title", that.attr("data-lecture"));
}
}
function reinitialiser_bouton_play_pause(media_id){
var that = $("." + media_id + " .play") ;
that.html("<span class='ui-icon-play'>play</span>")
.attr("title", that.attr("data-lecture"));
}
Loading…
Cancel
Save