diff options
author | Björn Stenberg <bjorn@haxx.se> | 2007-01-08 23:53:00 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2007-01-08 23:53:00 +0000 |
commit | 7039a05147b8bbfc829babea1c65bd436450b505 (patch) | |
tree | 4ba555eb84ed97b72b0575034d5b0530a393713e /songdbj/javazoom/jl/player/advanced/jlap.java | |
parent | 6d4c19707ef95942e323cbdc89fbbfdbe45e7cc5 (diff) | |
download | rockbox-7039a05147b8bbfc829babea1c65bd436450b505.tar.gz rockbox-7039a05147b8bbfc829babea1c65bd436450b505.zip |
Splitting out songdbj
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11953 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'songdbj/javazoom/jl/player/advanced/jlap.java')
-rw-r--r-- | songdbj/javazoom/jl/player/advanced/jlap.java | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/songdbj/javazoom/jl/player/advanced/jlap.java b/songdbj/javazoom/jl/player/advanced/jlap.java deleted file mode 100644 index beedea6716..0000000000 --- a/songdbj/javazoom/jl/player/advanced/jlap.java +++ /dev/null | |||
@@ -1,116 +0,0 @@ | |||
1 | /* | ||
2 | * 11/19/04 1.0 moved to LGPL. | ||
3 | *----------------------------------------------------------------------- | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU Library General Public License as published | ||
6 | * by the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU Library General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
17 | *---------------------------------------------------------------------- | ||
18 | */ | ||
19 | |||
20 | package javazoom.jl.player.advanced; | ||
21 | |||
22 | import java.io.BufferedInputStream; | ||
23 | import java.io.File; | ||
24 | import java.io.FileInputStream; | ||
25 | import java.io.IOException; | ||
26 | import java.io.InputStream; | ||
27 | |||
28 | import javazoom.jl.decoder.JavaLayerException; | ||
29 | |||
30 | /** | ||
31 | * This class implements a sample player using Playback listener. | ||
32 | */ | ||
33 | public class jlap | ||
34 | { | ||
35 | |||
36 | public static void main(String[] args) | ||
37 | { | ||
38 | jlap test = new jlap(); | ||
39 | if (args.length != 1) | ||
40 | { | ||
41 | test.showUsage(); | ||
42 | System.exit(0); | ||
43 | } | ||
44 | else | ||
45 | { | ||
46 | try | ||
47 | { | ||
48 | test.play(args[0]); | ||
49 | } | ||
50 | catch (Exception ex) | ||
51 | { | ||
52 | System.err.println(ex.getMessage()); | ||
53 | System.exit(0); | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | |||
58 | public void play(String filename) throws JavaLayerException, IOException | ||
59 | { | ||
60 | InfoListener lst = new InfoListener(); | ||
61 | playMp3(new File(filename), lst); | ||
62 | } | ||
63 | |||
64 | public void showUsage() | ||
65 | { | ||
66 | System.out.println("Usage: jla <filename>"); | ||
67 | System.out.println(""); | ||
68 | System.out.println(" e.g. : java javazoom.jl.player.advanced.jlap localfile.mp3"); | ||
69 | } | ||
70 | |||
71 | public static AdvancedPlayer playMp3(File mp3, PlaybackListener listener) throws IOException, JavaLayerException | ||
72 | { | ||
73 | return playMp3(mp3, 0, Integer.MAX_VALUE, listener); | ||
74 | } | ||
75 | |||
76 | public static AdvancedPlayer playMp3(File mp3, int start, int end, PlaybackListener listener) throws IOException, JavaLayerException | ||
77 | { | ||
78 | return playMp3(new BufferedInputStream(new FileInputStream(mp3)), start, end, listener); | ||
79 | } | ||
80 | |||
81 | public static AdvancedPlayer playMp3(final InputStream is, final int start, final int end, PlaybackListener listener) throws JavaLayerException | ||
82 | { | ||
83 | final AdvancedPlayer player = new AdvancedPlayer(is); | ||
84 | player.setPlayBackListener(listener); | ||
85 | // run in new thread | ||
86 | new Thread() | ||
87 | { | ||
88 | public void run() | ||
89 | { | ||
90 | try | ||
91 | { | ||
92 | player.play(start, end); | ||
93 | } | ||
94 | catch (Exception e) | ||
95 | { | ||
96 | throw new RuntimeException(e.getMessage()); | ||
97 | } | ||
98 | } | ||
99 | }.start(); | ||
100 | return player; | ||
101 | } | ||
102 | |||
103 | public class InfoListener extends PlaybackListener | ||
104 | { | ||
105 | public void playbackStarted(PlaybackEvent evt) | ||
106 | { | ||
107 | System.out.println("Play started from frame " + evt.getFrame()); | ||
108 | } | ||
109 | |||
110 | public void playbackFinished(PlaybackEvent evt) | ||
111 | { | ||
112 | System.out.println("Play completed at frame " + evt.getFrame()); | ||
113 | System.exit(0); | ||
114 | } | ||
115 | } | ||
116 | } \ No newline at end of file | ||