本文为大家分享了用java来播放mp3的具体代码,使用jl1.0.1.jar,供大家参考,具体内容如下
代码:
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
|
import java.io.bufferedinputstream; import java.io.fileinputstream; import javazoom.jl.player.player; /** * @author brandon b. lin * 2013-1-25 */ public class mp3player { public mp3player(string filename) { this .filename = filename; } public void play() { try { bufferedinputstream buffer = new bufferedinputstream( new fileinputstream(filename)); player = new player(buffer); player.play(); } catch (exception e) { system.out.println(e); } } public static void main(string[] args) { mp3player mp3 = new mp3player( "陈瑞 - 白狐.mp3" ); mp3.play(); } private string filename; private player player; } |
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://www.oschina.net/code/snippet_937173_17692