Bonsoir,
je cherche à lire un son mp3 et j'ai vu que la librairie jlayer était faite exactement pour ça.
Mais mon problème, c'est que dès que je run mon programme, j'ai juste le son qui tourne et je n'ai plus ma jframe qui apparaît...
Voici la classe que j'utilise pour le son mp3 :
Et voici comment je fais appel à cette classe:
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 import java.io.*; import javazoom.jl.player.advanced.*; // MP3, WMA, MPEG, WAV compatible public class Sound { private boolean isPlaying = false; private AdvancedPlayer player = null; public Sound(String path) throws Exception { InputStream in = (InputStream)new BufferedInputStream(new FileInputStream(new File(path))); player = new AdvancedPlayer(in); } public Sound(String path,PlaybackListener listener) throws Exception { InputStream in = (InputStream)new BufferedInputStream(new FileInputStream(new File(path))); player = new AdvancedPlayer(in); player.setPlayBackListener(listener); } public void play() throws Exception { if (player != null) { isPlaying = true; player.play(); } } public void play(int begin,int end) throws Exception { if (player != null) { isPlaying = true; player.play(begin,end); } } public void stop() throws Exception { if (player != null) { isPlaying = false; player.stop(); } } public boolean isPlaying() { return isPlaying; } }
Merci de votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 this.str = "Musiques/mariosuperbros.mp3"; File f = new File(str); try { this.s = new Sound(f.getAbsolutePath()); this.s.play(); } catch (Exception ex) { Logger.getLogger(drawing.class.getName()).log(Level.SEVERE, null, ex); }
Partager