• 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
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Hey! Dont ne One know About Java SOUND???!!

 
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Well I am trying to use Java Sound or Applet.AudioClip to play a wave or midi file..
This is my third post and yet no one has replied to the same..
I wonder if we still have those ranch hands, Bartenders and sheriffs who are still green horns on Java Sound.
Well here is some enlightenment for ya all..

The Above Code is supposed to play the Audio clip that I present .. but it doesnot. nor does it gimme any runtime/compiletime errors..
I ve been wondering why this is happenning..
well those who know please answer.. and those who dont cud @least thank me for enlightening them
Regds
Gautham Kasinath
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi gautham
if all you want is to play the audioclip, i would recommend that
you use JMF. of course u can use JavaSound, but JMF makes things
simpler..
here's a sample code :
player = Manager.createPlayer(new URL("file://foo.wav"));
player.start ();
that's it!!!
hope this helps.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello!
only *.au files can be played with yr.code.
i tried many times with other files but with no output.if you play any .au files it will work.some of them are in jdk demo directory.
for other files i think there is no support with the packages you imported.may be javax.sound.* may be helpful to you.
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Well cud you gimme a complete code please b coz I m new to JMF and I cudnt understand which class s' instance u r creating player as..
Regds
Gautham Kasinath
 
Stanley George
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
first u have to download JMF 2.1 from java.sun.com/
install jmf on ur machine
then run the foll code..
import javax.media.*;
import javax.media.rtp.*;
import java.net.*;
public class RTPPlayer implements ControllerListener {
Player player;
public RTPPlayer() {
try {
URL url = new URL("file://foo.wav.gsm");
player = Manager.createPlayer(url);
player.addControllerListener(this);
player.start ();
} catch (Exception e) {
}
}// RTPPlayer
public void controllerUpdate( ControllerEvent evt) {
}

public static void main (String args[]) {
RTPPlayer rtpPlayer = new RTPPlayer();
System.out.println ("starting to play...");
}
}
this is just a rough code..but will serve
the purpose.
you have to stop the player using player.stop();
otherwise it continues to run in the background.
happy coding
[This message has been edited by Stanley George (edited February 20, 2001).]
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Eureka!!
Mr. Georges' code Worked..
Hey I didnt see about my code working.. did it reallY.. because it did not work with me..
Anyway Mr. george or others cud you help me out with some streaming audio playing??
Actually I would like to have a link where theres tutorials on the Javax.sound extension of JMF.
Thanks a lot everybody for helping me hear the first sounds through a code.
Regds
Gautham Kasinath
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think what's happening is that your app is exiting before the audio gets a chance to actually play. Try using Thread.sleep after invoking play and see what happens.

Originally posted by gautham kasinath:
[B]

[/B]

 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I tried the Thread.sleep() at the code but that is not working.
I am not sure why..
Anyway the last post gave me an insight into how to play a clip using the javax.sound.* and that really worked.. ]
Thanks anyway
Please let me know what may be the problem.
Regds
Gautham Kasinath
 
Stanley George
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi gautham
glad to know that u r happy. i wish some 1 would help me out too.
even i am having some problems with straming media.
but its rather simple to start with.
and to tell u something, JMF uses JavaSound for its functionality
if u want some examples u could start with the user-guide of JMF
some really neat examples are listed there.
JMF-RTP could be the section you are looking out for..
happy coding.
and hey! call me stanley. lets all be friends
[This message has been edited by Stanley George (edited February 21, 2001).]
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! Stanley!!
Well I guess I will look around the JMF for more on streams.. and as soon as I hit some ting I shall cry out to ya!!
well sure less be friendz, well my full name is posted on the ranch gautham kasinath and I just passed out with a bachelors in Computer science and Engg. in India. I ve round a years exp. in Java and more specifically 7 months in real time Java based software dev. I also am a lover of C and C++, I ve exp in ASP as well..
my mail id is : [email protected] and I check my mails every 1/2 hr..
I shall be online on yahoo messenger as gkasinath
Please feel free to contact me in either of these ways, nd please let me know about u r self..
Regds
Gautham Kasinath
 
Stanley George
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi gautham
u can mail me at [email protected]
my yahoo messenger handle is indigoneptune
i'm interesed in real time java too...
glad to know that we share similar interests.

 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! Stanley!!
well I just added u to my list..
well actually i m interested not only in real time Java but every ting under the SUN..

anyway have you found a solution on streamed audio?? well I did go thru some materials on the JMF but I cudnt quite understand it.. I shall give it a few more parses and get bak to you.
regds
Gautham Kasinath
 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic