Results 21 to 35 of 35
Thread: Mp3 in background?
- 07-21-2011, 11:31 PM #21
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
I have no experience with sun.audio.* - see #14 for how I would play sound - but anyone who does is probably going to want a problem description. Does that file exist (a file with exactly that name)? Are there runtime errors (IOException)? What actually happens at runtime (sound, no sound etc)?(Reply #17) I get Using audio file /Users/seegee1237/NetBeansProjects/Celcius/300ViolinOrchestra.mp3
- 07-22-2011, 04:06 AM #22
Member
- Join Date
- Jul 2011
- Posts
- 36
- Rep Power
- 0
Ok, while using your code, this is what happens. Yes, that file exists, I copied and pasted the exact name. At runtime, I do get an IO exception that says this: java.io.IOException: could not create audio stream from input stream
at sun.audio.AudioStream.<init>(AudioStream.java:65)
at CJSMoneyMachine.main(CJSMoneyMachine.java:126)
Line 126 is: audioStream = new AudioStream(new FileInputStream("300ViolinOrchestra.mp3"));
Other than the music part, the whole rest of the program works fine. There is just no sound in the speakers.
- 07-24-2011, 10:59 PM #23
Member
- Join Date
- Jul 2011
- Posts
- 36
- Rep Power
- 0
Can anyone help me?
- 07-24-2011, 11:06 PM #24
Try another type of filejava.io.IOException: could not create audio stream from input stream
- 07-24-2011, 11:33 PM #25
Member
- Join Date
- Jul 2011
- Posts
- 36
- Rep Power
- 0
I tried a .wav file and got the same error. The wav file was about 3 seconds long.
- 07-24-2011, 11:58 PM #26
This code works for me:
Java Code:AudioPlayer AP = AudioPlayer.player; AudioStream AS; AudioData AD; ContinuousAudioDataStream loop= null; try { AS = new AudioStream(new FileInputStream("Audio/gong.wav")); // mp3 => java.io.IOException: could not create audio stream from input stream AD = AS.getData(); loop = new ContinuousAudioDataStream (AD); }catch (IOException error) {error.printStackTrace();} AP.start (loop);
- 07-25-2011, 12:30 AM #27
Member
- Join Date
- Jul 2011
- Posts
- 36
- Rep Power
- 0
Nope, got the same error again. I tried it in my program and In another class alone. I still got the same error :( Is there something wrong with my computer or something?
- 07-25-2011, 12:31 AM #28
Must be something different. What JDK and OS are you on?
- 07-25-2011, 02:03 AM #29
Member
- Join Date
- Jul 2011
- Posts
- 36
- Rep Power
- 0
I am using Java version 1.6.0_26 on Mac OSX 10.7. I was on 10.6 a few days ago but i was getting the same error. (I didn't have to download JDK or Java because it came with my mac)
- 07-26-2011, 01:35 PM #30
Member
- Join Date
- Jul 2011
- Posts
- 36
- Rep Power
- 0
Can anyone who is using mac osx test the code for me?
- 07-30-2011, 04:10 AM #31
Member
- Join Date
- Jul 2011
- Posts
- 36
- Rep Power
- 0
Does anyone have an audio code confirmed working on Mac Osx?
- 07-30-2011, 07:37 PM #32
Senior Member
- Join Date
- Nov 2010
- Posts
- 164
- Rep Power
- 3
I really don't know the clear answer to your question, but a really bad advice if you want to get this done is to hack a program that plays sound that was written in Java and see how it's coded. It's bad advice because it's often best to learn linearly as much of the basics as you can before blindly copying the code of others. Other people's code is meant to teach you how to solve problems in a way that has been done by someone else to expand your thinking, but if you don't know the basics, then you're setting yourself up for bad habits....such as using youtube to learn to code Java. Also, JDK 7 is out...
- 07-31-2011, 01:44 AM #33
Member
- Join Date
- Jul 2011
- Posts
- 36
- Rep Power
- 0
I do know the basics to java and this was the only time that I have ever looked on youtube for code. I always code my own stuff, my goal is not to make a good program. My goal is to learn Java and just copying codes all the time (which I don't do) is not the way to learn it. But I will try to get the source code of a program that plays audio.
- 07-31-2011, 02:39 AM #34
Senior Member
- Join Date
- Nov 2010
- Posts
- 164
- Rep Power
- 3
Okay. I was just offering some basic advice. If you know the basics, then one of the senior members (well super senior members) may be better suited to point you in the right direction. Hacking is a good way to learn though...! Good luck!
- 07-31-2011, 02:40 AM #35
Senior Member
- Join Date
- Nov 2010
- Posts
- 164
- Rep Power
- 3
Similar Threads
-
No background in FESM
By NatureFreshMilk in forum New To JavaReplies: 2Last Post: 07-08-2011, 11:17 AM -
How to Run a .exe in background???
By jazz2k8 in forum New To JavaReplies: 9Last Post: 01-21-2011, 11:27 AM -
Background in JFrame ( GUI).
By Twister03 in forum AWT / SwingReplies: 2Last Post: 03-12-2009, 03:24 AM -
Background image
By leiferouis in forum New To JavaReplies: 9Last Post: 03-08-2009, 05:49 PM -
BackGround & ForeGround
By hungleon88 in forum Advanced JavaReplies: 3Last Post: 08-31-2008, 07:20 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks