Results 1 to 7 of 7
- 02-22-2011, 01:05 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 4
- Rep Power
- 0
Accessing AudioSystem getMixerInfo()??
Would like to see how a simple program uses the getMixerInfo() to display the mixers that are installed on my computer. I am very new to Java and really appreciate any help and/or advice.
In Eclipse I set up a class like so:
import javax.sound.sampled.*;
public class DisplayMixers {
What do I need inside my class to call the object and display the name, version, vendor, description which are defined in the Mixer.Info class?
public void main (String [] args){
}
}Last edited by Jlister76; 02-22-2011 at 01:09 PM.
- 02-22-2011, 02:13 PM #2
You would need to have the AudioSystem class to invoke this method. It returns the details inside an array. I hope you know how to iterate over the array and display the information inside.
Here is the API link : AudioSystem.getMixerInfo()
Hope that helps,
GoldestJava Is A Funny Language... Really!
Click on * and add to member reputation, if you find their advices/solutions effective.
- 02-22-2011, 03:11 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 4
- Rep Power
- 0
First off thank you Goldest for your reply. This is the first time I have been able to ask anyone a question as I've been primarily reading from books & tuts.
I'm a still a bit confused as what to do to follow your instructions. Do I instantiate an object, then an array of the object and then print the values?
- 02-22-2011, 04:26 PM #4
The getMixerInfo() method is a static method, so you don't really need to create any object to access it. You can access it directly by the class name AudioSystem.
This method returns an array of Info objects for the currently installed mixers. You need to store the output into Info[] array, iterate over it and display the contents.
I hope you can manage that,
GoldestJava Is A Funny Language... Really!
Click on * and add to member reputation, if you find their advices/solutions effective.
- 02-25-2011, 12:19 AM #5
Member
- Join Date
- Feb 2011
- Posts
- 4
- Rep Power
- 0
Mission accomplished!
Once again thank you for your help. A breakdown of my code is below and would like to know is there a more efficient way to produce the same results?
I imported both AudioSytem and Mixer class.
Accessed the method and stored the objects into an array as you advised
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo()
Then iterated over the array using a try/catch and a for statement
try {
System.out.println("Available mixers:");
for (int cnt = 0; cnt < mixerInfo.length;
cnt++) {
System.out.println(mixerInfo[cnt].getVersion());
System.out.println(mixerInfo[cnt].getName());
System.out.println(mixerInfo[cnt].getDescription());
System.out.println(mixerInfo[cnt].getVendor());
}//end for loop
} catch (Exception e) {
// nada
- 02-25-2011, 07:00 AM #6Java Is A Funny Language... Really!
Click on * and add to member reputation, if you find their advices/solutions effective.
- 02-25-2011, 01:04 PM #7
Member
- Join Date
- Feb 2011
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Accessing XML in a Jar
By WizzRD in forum Advanced JavaReplies: 19Last Post: 07-29-2010, 01:20 PM -
Can't hear the wav file im playing :( (using AudioSystem)
By Addez in forum New To JavaReplies: 3Last Post: 03-03-2010, 10:51 PM -
Accessing USB
By FieryProphet in forum NetworkingReplies: 3Last Post: 12-13-2008, 06:29 AM -
Accessing file
By Doctor Cactus in forum New To JavaReplies: 1Last Post: 10-24-2008, 08:31 PM -
problem in accessing EJB
By parimal in forum Enterprise JavaBeans (EJB)Replies: 0Last Post: 08-07-2008, 04:31 PM
Bookmarks