Bonjour à tous,

Voici un code d'un lecteur mp3 utilisé sur le site d'un client,
Tout fonctionne à part le passage d'une piste à une autre.
A la fin d'une piste, j'ai la mention 'undefined' qui s'affiche, au lieu de passer à la track suivante
La question est : Pourquoi est il si méchant ?

Voici le code, avec la partie concernée en gras :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
var temps = 0;
var total = 0;
var resultat = 0;
// Gestion du XML
playlist_xml = new XML();
playlist_xml.ignoreWhite = true;
playlist_xml.onload = function(ok) {
if (ok = true) {
playliste = this.firstChild.childNodes;
premiere = this.firstChild.firstChild;
enCours = premiere;
for (i = 0;i < playliste.length; i++) {
// trace ("num="+enCours.attributes.num+", nom="+enCours.attributes.nom+", fichier="+enCours.attributes.fichier+".");
liste.addItem(enCours.attributes.num + " : " + enCours.attributes.nom, enCours.attributes.fichier);
enCours = enCours.nextSibling;
}
}
};
playlist_xml.load("playlist.xml");
//
// Gestion du chargement des mp3s
//
chanson = new Sound();
chanson.onload = function(ok) {
if (ok = true) {
chanson.start();
_root.ecranTitre = liste.getSelectedItem().data;
titrejoue = liste.getSelectedItem().data;
timer.onload = function () {
volumechanger.setVolume(_root.volume);
}
timer.onEnterFrame = function () {
volumechanger.setVolume(_root.volume );
temps = chanson.position;
total = chanson.duration;
resultat = Math.floor((temps/total)*100);
volumechanger.setVolume(_root.volume );
timesec = Math.floor(temps/1000)-60*tpsmin; // temps en secondes
if(timesec<10){ // ajout du 0
tpssec = "0"+timesec;
}else if(timesec>10){
tpssec = timesec;
}
timetotsec =Math.floor(total/1000)-60*totmin;
if(timetotsec<10){ // ajout du 0
totsec = "0"+timetotsec;
}else if(timetotsec>10){
totsec = timetotsec;
}
timetpsmilli = temps-Math.floor(temps/1000)*1000;// en millisecondes
if(timetpsmilli<100){ // ajout du 0
tpsmilli = "0"+timetpsmilli;
}else if(timetpsmilli>100){
tpsmilli = timetpsmilli;
}
timetotmilli = total-Math.floor(total/1000)*1000;
if(timetotmilli<10){ // ajout du 0
totmilli = "00"+timetotmilli;
}else if(timetotmilli>10 && timetotmilli<100){
totmilli = "0"+timetotmilli;
}else{
totmilli = timetotmilli;
}
timetpsmin = Math.floor(temps/1000/60); // en minutes
if(timetpsmin<10){ // ajout du 0
tpsmin = "0"+timetpsmin;
}else if(timetpsmin>10){
tpsmin = timetpsmin;
}
timetotmin = Math.floor(total/1000/60);
if(timetotmin<10){ // ajout du 0
totmin = "0"+timetotmin;
}else if(timetotmin>10){
totmin =timetotmin ;
}
}
} else {
_root.ecranTitre = "...Problème au chargement...";
deselection();
}
};
_root.chanson.onSoundComplete = function() {
_root.ecranTitre = "...Chanson terminée...";
fichiersuivant = fichierEnCours.getSelectedIndex();
//fichier = new String(liste.getSelectedItem().label);
//numerofichier = fichier.slice(0,2);
//numsuiv = new Number(numerofichier)+1;
//fichiersuivant = new String (numsuiv+":");
trace(fichiersuivant);
//if (fichiersuivant = "undefined"){
//fichiersuivant = new String(1: );
//}else{
//_root.chanson.loadSound(fichierEnCours, true);
//}
};
//
// Gestion du clic dans la liste
//
_root.liste.setSelectMultiple(false);
_root.liste.setChangeHandler("userClic");
function userClic() {
fichierEnCours = liste.getSelectedItem().data;
_root.chanson.loadSound(fichierEnCours, true);
}
function deselection() {
_root.liste.setSelectedIndices(null);
}
 
// gestion des boutons
test = 0;
_root.arret.onPress = function() {
stopAllSounds();
_root.ecranTitre = "...Arret exécuté...";
test = 0;
duree = 0;
}
 
_root.lancement.onPress = function() {
if (test = 1) {
chanson.start(duree,0);
_root.ecranTitre = titrejoue
test = 0;
}else{
chanson.start();
_root.ecranTitre = titrejoue;
resultat = 0;
}
}
_root.pose.onPress = function() {
chanson.stop();
duree = chanson.position/1000;
test = 1;
_root.ecranTitre = "...Mise en pause...";
}
 
_root.retour.onPress = function() {
duree = Math.round(chanson.position/1000);
chanson.stop();
_root.ecranTitre = "...Retour de 15 secondes...";
}
_root.retour.onRelease = function() {
chanson.start(duree-15,0);
_root.ecranTitre = titrejoue;
}
 
_root.avance.onPress = function() {
duree = Math.round(chanson.position/1000);
chanson.stop();
_root.ecranTitre = "...Avance de 15 secondes..."; 
}
_root.avance.onRelease = function() {
chanson.start(duree+15,0);
_root.ecranTitre = titrejoue;
}
 
// gestion du volume
 
increment = 4;
level1 = 0;
volume = 50;
 
slider.onPress = function() {
if (Key.isDown(Key.getCode(18))) {
autoPan = true;
} else {
autoPan = false;
start = _root._xmouse;
newStart = slider._rotation;
dragging = true;
}
};
slider.onRelease = function() {
dragging = false;
};
slider.onReleaseOutside = function() {
dragging = false;
};
//
this.onEnterFrame = function() {
if (dragging) {
pivot = (_root._xmouse-start)*2+newStart;
slider._rotation = pivot;
if (pivot<-135) {
slider._rotation = -135;
}
if (pivot>135) {
slider._rotation = 135;
}
if (volume<=8 && volume != 0){
couleur8._alpha = 100
}
_root.level1 = Math.round(slider._rotation/2.7);
_root.volume = Math.round(level1+50);
} else {
if (autoPan) {
_root.textInput.value.selectable = false;
level1 += increment;
_root.volume = Math.round(level1+50);
if (level1>49 || level1<-49) {
increment *= -1;
}
} else {
_root.textInput.value.selectable = true;
}
if (level1>50) {
level1 = 50;
_root.volume = Math.round(level1+50);
} else if (level<-50) {
level1 = -50;
_root.volume = Math.round(level1+50);
} else if (level1<=50 && level1>=-50) {
_root.slider._rotation = level1*2.7;
_root.volume = Math.round(level1+50);
}
}
_root.volumechanger.setVolume(volume);
};
Merci d'avance..