Bonjour à vous,

Je viens de m'abonner a ce forum et je commence a faire des jeux pour cellulaire et j'aimerais savoir comment faire pour charger en mémoire des son. J'ai penser lire un fichier et enregistrer el fichier dans un tableau de byte. Mais je ne cesse d'avoir des exception et j'aimerais davoir comment mis prendre. Voilà comment j'ai fais jusqu'a maintenant.

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
 
public class Sound {
             private String name, type;
	private byte []data;
 
	public Sound(String name, byte []data, String type) {
		this.data = data;
		this.name = name;
		this.type = type;
	}
 
             public boolean load() {
		if (name.equals("")) return false;
 
		try {
			InputStream in = getClass().getResourceAsStream(name);
			if (in==null) return false;
			ByteArrayOutputStream out = new ByteArrayOutputStream();
			byte []byteToRead = new byte[1024];
 
			while (in.read(byteToRead) > 0)
                out.write(byteToRead, 0, byteToRead.length);						
 
			this.data = out.toByteArray();
			in.close();			
			out.close();
		}
		catch (IOException e) {
			e.printStackTrace();
			return false;
		}
 
		return true;
	}
 
             public static void main(String []args) {
		Sound unSon = new Sound("/s0.mid", null, "audio/midi");
		if (unSon.load()) {
			try {
                                            if (unSon.isLoaded()) {
                                                 javax.microedition.media.Player myPlayer = javax.microedition.media.Manager.createPlayer(new ByteArrayInputStream(unSon.getData()),unSon.getType());
 
                                                 myPlayer.realize();
                                                 myPlayer.prefetch();
                                                 myPlayer.start();
                                            }				
			}
			catch (Exception e) {
                                            e.printStackTrace();
                                      }
 
		}
		else System.out.println("Le son n'existe pas");
	}
}
Merci de m'aider la dessus. Alors voila en gros comment je fais J'ai pas mis les fonction d'accès mais sacher kil existe dans ma classe. Merci d'avance