!752 static S musicID = "#1001093"; static int songDuration, seekValue; static long songBytes; static int position; static new JSlider seeker; static new JLabel text; p-awt { substanceLAF("Moderate"); //File mp3 = loadLibrary(musicID); // deh polish music // OK, .wav works. //File mp3 = new File("/media/CE009E97009E865D__/stuff/Musik/mp3/recorded/say something.wav"); // Let's try OGG. (Works with fixing of classpath.) File mp3 = new File("/media/CE009E97009E865D__/stuff/Musik/UFDD - The Greetings Part.ogg"); // Let's try MP3. Works now too! //File mp3 = new File("/media/CE009E97009E865D__/stuff/Musik/10. Odyssey - If you're looking for a way out.mp3"); // Fixing the classpath for Java Sound (MP3 + OGG) fixContextClassLoader(); JFrame frame = showFrame(centerAndEast(seeker, text)); frame.pack(); setFrameWidth(frame, 500); BasicPlayer player = makeBasicMP3Player(); player.addBasicPlayerListener(new BasicPlayerListener { public void opened(Object stream, Map properties) { for (Object key : properties.keySet()) print("opened: " + key + "=" + properties.get(key)); final Number bytes = (Number) properties.get("audio.length.bytes"); // Try to find duration of song long microseconds = 0; O duration = properties.get("duration"); if (duration instanceof Number) microseconds = ((Number) duration).longValue(); else pcall { long frames = asLong(properties.get("audio.length.frames")); long fps = asLong(properties.get("audio.framerate.fps")); microseconds = frames*1000000/fps; } print("Song Duration: " + microseconds); final long _microseconds = microseconds; awt { songDuration = (int) (_microseconds / 1000); seeker.setMaximum(songDuration); seeker.setEnabled(true); updateText(); songBytes = bytes.longValue(); } } public void progress(int bytesread, final long microseconds, byte[] pcmdata, Map properties) { //System.out.println("pcmdata: "+ pcmdata[0] + " " + pcmdata[1]); awt { //print("Progress: ms=" + microseconds); if (!seeker.getValueIsAdjusting()) { int ms = (int) (microseconds / 1000) + seekValue; seeker.setValue(ms); position = ms; updateText(); } } } public void stateUpdated(BasicPlayerEvent event) { awt { updateStateStuff(); } } public void setController(BasicController controller) {} }); player.open(mp3); player.play(); } svoid updateStateStuff { } svoid updateText { text.setText(formatMinuteAndSeconds(position/1000) + " / " + formatMinuteAndSeconds(songDuration/1000)); }