aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes How To Play Loop Audio In Java Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "How To Play Loop Audio In Java Application" Watch "How To Play Loop Audio In Java Application" New topic
Author

How To Play Loop Audio In Java Application

nayan rami
Ranch Hand

Joined: Dec 28, 2010
Posts: 30
hello Friends

how to use audio file to play in loop in java swing application


i am using this code but not give me a result and
is there any specific format used for that?




thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

You should start by never ever using any class in a package that starts with com.sun, sun or sunw. That includes sun.audio.AudioStream. The reason is that these classes are undocumented, and can be changed or even dropped in any next release of Java. Unfortunately, because programmers do not heed this warning, there are applications that stop working all of a sudden when a new Java version is installed. I myself found an application that only worked with Java 1.4.2_08. Even my 1.4.2_10 (at the time) Java installation refused to run the program. The cause, as indicated by the stack trace, as the use of one of these undocumented classes.

JMF is usually the way to go when wanting to play music and/or video in Java, but I found JLayer to be a little bit more intuitive to use.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41870
    
  63
JMF is usually the way to go when wanting to play music and/or video in Java

For MP3s -as in the code above- I'd agree, but for other formats (like AIFF, WAV and MIDI) the Java Sound API might be a better choice, as it is part of the JRE. I'd even go as far as saying that unless the point of the application is to play MP3s specifically, it may be preferable to convert the audio files to a format that Java Sound can handle, thus avoiding having to deal with JMF. (Which, although functional, hasn't been updated in years, partly relies on native code, is not part of the JRE etc.)


Ping & DNS - my free Android networking tools app
nayan rami
Ranch Hand

Joined: Dec 28, 2010
Posts: 30
Rob Spoor wrote:You should start by never ever using any class in a package that starts with com.sun, sun or sunw. That includes sun.audio.AudioStream. The reason is that these classes are undocumented, and can be changed or even dropped in any next release of Java. Unfortunately, because programmers do not heed this warning, there are applications that stop working all of a sudden when a new Java version is installed. I myself found an application that only worked with Java 1.4.2_08. Even my 1.4.2_10 (at the time) Java installation refused to run the program. The cause, as indicated by the stack trace, as the use of one of these undocumented classes.

JMF is usually the way to go when wanting to play music and/or video in Java, but I found JLayer to be a little bit more intuitive to use.



how can in loop mp3 or any other file format using JMF

i have to use some specific file format so and using in application not in applet
help me
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41870
    
  63
nayan rami wrote:how can in loop mp3 or any other file format using JMF

The javax.media.bean.playerbean.MediaPlayer class (which comes with JMF) has methods to set/unset/check loop mode.

i have to use some specific file format so and using in application not in applet

Which file format is that? Specifically MP3? Or would something else be OK as well?
 
 
subject: How To Play Loop Audio In Java Application