• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How To Play Loop Audio In Java Application

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.)
 
nayan rami
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic