Playing an AudioClip in a Thread...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Laura_Vita
Posted On:   Wednesday, April 9, 2003 09:05 PM

Is this code correct to play an audioClip on a Thread? Maybe something wrong because I can't listen any sound import java.applet.*; import java.net.*; class Audio { private AudioClip clip; private URL url; Audio() throws Exception { try { url = new URL("file:./Sounds/trick.wav"); } catch (MalformedURLException e) { } clip = Applet.newAudioClip(url); } void listen() throws Exception { clip.play(); } } import java.applet.Applet; import java.net.URL;    More>>

Is this code correct to play an audioClip on a Thread?

Maybe something wrong because I can't listen any sound




			
				
import java.applet.*;
import java.net.*;

class Audio {

private AudioClip clip;
private URL url;

Audio() throws Exception
{
try
{
url = new URL("file:./Sounds/trick.wav");
}
catch (MalformedURLException e) { }
clip = Applet.newAudioClip(url);
}

void listen() throws Exception
{
clip.play();
}

}

import java.applet.Applet;
import java.net.URL;
import java.applet.AudioClip;

class exemple implements Runnable
{
public exemple()
{
Thread thread1 = new Thread(this);
thread1.start();
}

public void run()
{
performAudioClip();
}

private void performAudioClip() throws Exception
{
Audio fx = new Audio();
fx.listen();
}
}
   <<Less

Re: Playing an AudioClip in a Thread...

Posted By:   Laura_Vita  
Posted On:   Sunday, April 13, 2003 11:16 AM

I didn't think this was a difficult question :|
About | Sitemap | Contact