Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Application with sound???

0 views
Skip to first unread message

Torgny Johansson

unread,
May 30, 2000, 3:00:00 AM5/30/00
to
Can anyone please give me an example of how to make a stanalone application
play a soundfile? I just can't get it to work.

How do I play a local music *.wav file in an application???

Thanks!

Mats Forssblad

unread,
May 30, 2000, 3:00:00 AM5/30/00
to

Sirkus S. Sirkus

unread,
Jun 3, 2000, 3:00:00 AM6/3/00
to

Well, assuming you're using Java 2 (i.e. jdk 1.2 or better) look at
using the static method "newAudioClip(url)" in Applet. Becuase
the method is static, you can use this even if you're not writing
an applet. Use this to get an audio clip, then play the audio clip.
Look it up in the java2 API.

sirkus

http://java.sun.com/j2se/1.3/docs/api/index.html


In article <8h19h2$526$1...@zingo.tninet.se>, "Torgny Johansson"


<torgny_j...@bigfoot.com> wrote:
> Can anyone please give me an example of how to make a stanalone
> application play a soundfile? I just can't get it to work.
>
> How do I play a local music *.wav file in an application???
>

> Thanks!
>
>

odinre...@yahoo.com

unread,
Jun 6, 2000, 3:00:00 AM6/6/00
to
But if you not are using java2....many does not use it.....
I wrote a soundclass for application that not is using the java1.2
library...its easy to use..

download at www.angelfire.com/games/cyroxx/files/CyroXXSound.zip

its just a single class file...

use the constructor CyroXXSound(String) or CyroXXSound(File)...
after that it works as a simple AudioClip....

good luck!

Sent via Deja.com http://www.deja.com/
Before you buy.

Steve DeGroof

unread,
Jun 9, 2000, 3:00:00 AM6/9/00
to
In article <8h19h2$526$1...@zingo.tninet.se>,
"Torgny Johansson" <torgny_j...@bigfoot.com> wrote:
> Can anyone please give me an example of how to make a stanalone
application
> play a soundfile?

There's source for SoundPlayer here. It takes care of all
the messing around to get a sound file to play:

http://degroof.home.mindspring.com/java/index.html

Here's source that uses it:

import nightshade.audio.*;
public class Sound
{
public static void main(String argv[])
{
SoundPlayer player = new SoundPlayer();
player.add("c:\\windows\\media\\tada.wav","tada");
player.add("c:\\windows\\media\\canyon.mid","canyon");
player.add("c:\\windows\\media\\notify.wav","beeboop");
player.play("tada");
player.play("canyon");
player.loop("beeboop");
try{Thread.sleep(3000);}catch(Exception e){};
player.stop("beeboop");
try{Thread.sleep(3000);}catch(Exception e){};
}
}

--
=============================================================
Steve DeGroof (deg...@mindspring.com)
http://degroof.home.mindspring.com
=============================================================

0 new messages