Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Old 10-06-2004, 08:35 PM Java Play Sounds
jazee's Avatar
Super Talker

Posts: 121
Location: Westminster, CO / Denver
Trades: 0
I have been programing java for a while now and i have finaly needed to learn how to play sounds. I have looked all over the internet on how to do this and i have found a lot of stuff. I'm trying to work with one code that i found wich is much like this
Code:
import java.applet.*;

AudioClip sound = getAudioClip(getCodeBase(), "file.mp3");
i have tryed this but for some reason getCodeBase() will not work. If you can help me fix this or you know a better way to play audio files in an application.
jazee is offline
Reply With Quote
View Public Profile Visit jazee's homepage!
 
 
Register now for full access!
Old 10-07-2004, 08:59 PM
Experienced Talker

Posts: 30
Trades: 0
Have you tried running the class file in cmd to make sure its not a code or syntax error?
andyc23 is offline
Reply With Quote
View Public Profile
 
Old 10-08-2004, 09:58 PM
jazee's Avatar
Super Talker

Posts: 121
Location: Westminster, CO / Denver
Trades: 0
ok I got a hold of someone and now I got it fix. But thanks for the help
jazee is offline
Reply With Quote
View Public Profile Visit jazee's homepage!
 
Old 10-08-2004, 10:05 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
Could you post your solution for future users who may run into the same problem?
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 10-11-2004, 09:23 PM
jazee's Avatar
Super Talker

Posts: 121
Location: Westminster, CO / Denver
Trades: 0
Code:
import java.net.MalformedURLException;
import java.net.URL;
import java.applet.*;

class name {
URL codeBase, fullpath; AudioClip soundclip; public void name(){
try {
codeBase = new URL("file:" + System.getProperty("user.dir") + "/"); fullpath = new URL(codeBase, "soundclipname.wav");
} catch (MalformedURLException e) {
System.err.println(e.getMessage());
}
soundclip = Applet.newAudioClip(fullpath); }
//To Play soundclip.play(); //To Loop soundclip.loop(); //To Stop soundclip.stop(); }
From what i have found you can only use *.au and *.wav files *.mp3 will not work. I haven't yet tryed any other file types yet. I think that is all the import statments needed not sure. I have only tested this as an application. So try it in an applet. Give feed back if it works and if other file types will play. You must also call the meathod at least once before you try and play the soundclip or you will get nullpointerexception errors. Try it out and see what you get.
jazee is offline
Reply With Quote
View Public Profile Visit jazee's homepage!
 
Reply     « Reply to Java Play Sounds
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31063 seconds with 12 queries