Playing an MP3 with Java using the Java Media Framework
After much futzing around, I have figured out how to play an MP3 using JMF from a given start time to a given stop time. The JMF Programmer's Guide turns out to be quite friendly.
Bonus: Can you tell which scripting language this was written in?
Bonus: Can you tell which scripting language this was written in?
import java.io.*
import javax.media.*
player = Manager.createPlayer(new MediaLocator(new File("c:/Documents and Settings/Jon/My Documents/My Music/MP3/Various Artists/Listen (cd 4 of 6)/01-R. Schumann _ Carnaval, Eusebius.mp3").toURL().toExternalForm()))
player.realize()
while (player.getState() == Controller.Unrealized || player.getState() == Controller.Realizing) {
Thread.sleep(100)
}
print "Duration: " + player.duration.seconds
player.mediaTime = new Time(Time.ONE_SECOND*5)
player.stopTime = new Time(Time.ONE_SECOND*10)
player.start()
0 Comments:
Post a Comment
<< Home