все вопросы по Java которые задают более 3х раз на форуме
Воспроизводим MP3
Запись от mutagen размещена 19.07.2013 в 17:13
Java | 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
| package jmftest;
import java.io.File;
import java.io.IOException;
import javax.media.Format;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.PlugInManager;
import javax.media.format.AudioFormat;
/**
* @author mutagen
*/
public class JMFTest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
File mp3 = new File("/path/to/file.mp3");
Format input1 = new AudioFormat(AudioFormat.MPEGLAYER3);
Format input2 = new AudioFormat(AudioFormat.MPEG);
Format output = new AudioFormat(AudioFormat.LINEAR);
PlugInManager.addPlugIn(
"com.sun.media.codec.audio.mp3.JavaDecoder",
new Format[]{input1, input2},
new Format[]{output},
PlugInManager.CODEC);
Player player = null;
try {
player = Manager.createPlayer(new MediaLocator(mp3.toURI().toURL()));
} catch (IOException ex) {
ex.printStackTrace();
} catch (NoPlayerException ex) {
ex.printStackTrace();
}
player.start();
}
} |
|
|
Всего комментариев