1. Implement with Applet: (simplest method)
Java code AudioClip player = applet.newaudioclip (URL); AudioClip Introduction: The AudioClip interface is a simple abstraction for playing audio clips. Multiple AudioClip items can be played at the same time and the resulting sound is mixed together to produce a synthetic sound. Repeat: Player.loop ();/a sentence is done.
AudioClip player = applet.newaudioclip (URL);
AudioClip Introduction:
The AudioClip interface is a simple abstraction for playing audio clips. Multiple AudioClip items can be played at the same time and
the resulting sound is mixed together to produce a synthetic sound.
repeat: Player.loop ();/a sentence is done.
2. Through the JDK with the audio implementation
Java code sun.audio.audioplayer;//player sun.audio.audiostream;//audio stream do {inputstream = Url.openstream () //Get the input stream of the music file Audiostream as = new Audiostream (IS);//create the audio stream AudioPlayer.player.start (as);/start playing while loop &&as.available () > 0);//If you want to implement a repeat, you must stop here, or you will always have the beginning, because you have been reading repeatedly} while (loop);
sun.audio.audioplayer;//player
sun.audio.audiostream;//audio stream do
{
InputStream = Url.openstream ();// Get the input stream for the music file
audiostream as = new Audiostream (IS);//create the audio stream
AudioPlayer.player.start (as);/start the While
loop &&as.available () > 0);//If you want to implement a repeat, you must stop here, or you will always have the beginning, because you have been reading repeatedly
} while (loop);
3. Implemented through JMF
Java code Player player = manager.createplayer (URL);//Create Player Object Player.addcontrollerlistener (New controllerlistener () {//plus the corresponding control listener @Override public void controllerupdate (controllerevent e) { // todo auto-generated method stub if (e instanceof Endofmediaevent) {//if played to the end of the audio file, start playback again player.setmediatime (new time (0) ); player.start (); } if (e instanceof Prefetchcompleteevent) {//prefetch refers to a state of the player player.start ();  &NBSP} } }); player.prefetch ()//This is used to trigger the second time the above listener corresponds to start playing audio file