@Chattyboy123 yes but you must make a compiler (you can do that in notepad to just save you'r compiler as .bat) and then save this code as .java, you can find a tutorial on how to do this on youtube! ;)
Cool but mine is not playing. I caught 2 exceptions. FileNotFound Exception that should print File not found in a box, then an IOException that prints Error 101 in a box.
Well, everytime I clack a button, it prints the IOException ie "Error 101". What did I do wrong?
and again, I already have a GUI with multiple buttons. I just added music on one of them. HELP!
@2good4youboi In your Eclipse, do this: Click on File -> Properties -> Resource. (Do not click on the arrow thing in front of resource. Just look at the right side, you will see "Location:" ). That's where it is.
I have a similar problem to some people. I am using Notepad++ and running the program on cmd Compiler. No errors, 7 warning so it can run, but when i do i can't hear any music. I am using an mp3 file, and i have tried to call the method in other methods and it doesn't work. Any help??????????????????????????????
i can ONLY make this on netbeans. eclipse says stuff about restriction and when i turned the errors into waring it still had two other errors! and on netbeans no audio plays
@marketanarchist2011 u might be using wrong type of sound file. You have to use a wav file for it to play + it has to be short or unconverted. I did the same way and it does not play long wavs, like normal 4mb tracks.
thank u brother...thanx a lot. have been searching this at breath's end.this was to the ultimate rescue.just showed 7warnings but worked absolutely fine.
My program builds but no music plays. I'm using a .wav file I followed all the steps. Sorry man but this didn't really help me. Guess I need to try again
Thank you so much, this video was a BIG help. The only issue I had was I had to place "String[ ] args" in "public static void (String[ ] args)". Otherwise it worked very well. thanks
How would you stop the loop? i have tried MGP.stop(loop); but that doesnt work... when i run the program it just keeps running until i close out of eclipse.
on the tool bar go to Windows -> Preferences -> Java -> Compiler -> Errors/Warnings. Change the forbidden references to "warning". This will allow it to run. For some reason I use pics or audio on my java.
In eclipse do this: Window -> Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference (access rules) -> set it to 'Warnings'
You can put the full path of the file instead of just putting the file name. That way the program will know exactly where to look. For example you can put "C:/Users/My Documents/Safari2.mp3" instead of putting the file name
Can you do all of this on notepad? :P
Chattyboy123 3 weeks ago
@Chattyboy123 yes but you must make a compiler (you can do that in notepad to just save you'r compiler as .bat) and then save this code as .java, you can find a tutorial on how to do this on youtube! ;)
MattiasRosendahl 2 weeks ago
@MattiasRosendahl really? I saved it under .jar! O_O!
Chattyboy123 1 week ago
@MattiasRosendahl Could you send me a link to that?
Chattyboy123 1 week ago
@Chattyboy123 just search, i dont rly have much time lol. if u dont find it on youtube, try google :D
MattiasRosendahl 5 days ago
Why can't i play the music??
vtn08 3 weeks ago
Yo lo hice en netbeans seguí los mismo pasos, y no me sale ningún error asta me sale el cuadro de "Click me" jejej pero no me SUENA!!! porque??
ayuda!!!!!
21sebas12 1 month ago
There's a JMF (Java Media Framework) plug-in for MP3 support, but it doesn't support the more common formats floating around the net. Use JavaZoom.
blackcompe 2 months ago
That's an awesome cursor...
TheNickMead 2 months ago
You dumbass. You can't use sun packages anymore.
Broken ass Java bullsh8
eschelar 3 months ago
@eschelar uhm. You do realize this video is from 2009. Who's the dumbass now?
jimmykudo0 2 months ago 4
motherfucking gross indian say what motherfucker java
heavyrain24 3 months ago
your mouse icon is fucking annoying.
vaporeek 3 months ago 2
This will solve all your problems
Enter my-app-throws-java-io-ioexception-could-not-create-audiodata-object ... it will take you to a stackoverflow page
Swiftray1 3 months ago
I got it to work but it wont place sound PS I am using a wav file
rachcat4 3 months ago
It says it cannot find the class FileInputStream
MrGreatMatsby 4 months ago
I have tried to play the sound (*.mp3)
But I am getting exception error :
java.io.IOException: could not create audio stream from input stream
Please Reply...
farazhashmi9000 4 months ago
im using the javac command and a simple text editor to write code, and this didnt help, any suggestions?
pkflyers 4 months ago
Cool but mine is not playing. I caught 2 exceptions. FileNotFound Exception that should print File not found in a box, then an IOException that prints Error 101 in a box.
Well, everytime I clack a button, it prints the IOException ie "Error 101". What did I do wrong?
and again, I already have a GUI with multiple buttons. I just added music on one of them. HELP!
RASHTG 4 months ago
Where do you find the folder that you projects and stuff r in tht you import the .wav file to?
2good4youboi 4 months ago
@2good4youboi In your Eclipse, do this: Click on File -> Properties -> Resource. (Do not click on the arrow thing in front of resource. Just look at the right side, you will see "Location:" ). That's where it is.
RASHTG 4 months ago
Comment removed
HoMiNGHeaD 4 months ago
This has been flagged as spam show
not working for me. maybe it only works for wav files and the file should be small
ojstrike 5 months ago
Comment removed
ojstrike 5 months ago in playlist Mr. java Help GUI (good)
I have a similar problem to some people. I am using Notepad++ and running the program on cmd Compiler. No errors, 7 warning so it can run, but when i do i can't hear any music. I am using an mp3 file, and i have tried to call the method in other methods and it doesn't work. Any help??????????????????????????????
FlyOfDarkness 5 months ago
@FlyOfDarkness nvm, got it to work :D
FlyOfDarkness 5 months ago
Some people don't have Eclipse
lauraps2 5 months ago
I Got Exception "could not create audio stream from input stream"
umerk44 5 months ago
i can ONLY make this on netbeans. eclipse says stuff about restriction and when i turned the errors into waring it still had two other errors! and on netbeans no audio plays
James18998 5 months ago
whats the compiler thingy ur using
MrJohnboyofsj 5 months ago
@MrJohnboyofsj He's using Eclipse . . . that's the thingie me old cock sparrow!
arthurmee 5 months ago
i did exactly what he did and it doesnt work
cant hear any sound
marketanarchist2011 5 months ago
@marketanarchist2011 u might be using wrong type of sound file. You have to use a wav file for it to play + it has to be short or unconverted. I did the same way and it does not play long wavs, like normal 4mb tracks.
FlyOfDarkness 5 months ago
i finally followed schintus suggesting and got it to work but i have a problem ending the music file when it close
it would just continue to play
i had to eventually go to the window task manager and stop it
awesomelemonade 5 months ago
Comment removed
awesomelemonade 5 months ago
thank u brother...thanx a lot. have been searching this at breath's end.this was to the ultimate rescue.just showed 7warnings but worked absolutely fine.
grave386 5 months ago
HOW DO YOU CHAGNE THE VOLUME?!??!?!?
MinecraftingDaddio 6 months ago
it said that i needed to do something with rt.jar
awesomelemonade 6 months ago
Hmm I'm not getting any music to play.. It's probably the way I've typed it though.
Quaker763 7 months ago
the program runs without errors or warnings but nothing is played.
tewari2312 7 months ago
did everything...but get 7 warnings..all saying like this :-
sun.audio.AudioPlayer is Sun proprietary API and may be removed in a future release
need help...
deven981 7 months ago
thank you ... ^_^
DrAmeerh 8 months ago
could you add a copy of the program in the comment section
qawsedrftgyhukikolp 8 months ago
This feels messy D:
mattrocks182 8 months ago
My program builds but no music plays. I'm using a .wav file I followed all the steps. Sorry man but this didn't really help me. Guess I need to try again
CoilMercurialFYZX 8 months ago
@CoilMercurialFYZX I take it backkkkk IT WORKS!!!! YEEEEES!!!!! YOU ARE KIIIING!!!!!
CoilMercurialFYZX 8 months ago
@CoilMercurialFYZX How did you get it to work? It's not doing it for me...
Hikarikun92 6 months ago
doesn't work :O
MrJimarla 8 months ago
Why the need for the sun* apis? Doesn't java have a standard sound api? The sun apis are not cross platform. They may not be there in every Java.
Good vids though. ;)
sproket888 9 months ago
tanks !!
DanyGsFgRs 9 months ago
I followed this thing completely, no compile error or anytihng, can't hear any sound anyways! Any that knows why possibly?
rickardny 9 months ago 8
@rickardny Editted : Worked! Wrong format!
rickardny 9 months ago
@rickardny turn ur volume up :)
James18998 5 months ago
Awesome tutorial BRO. It worked. Thanks.
mmkirby2 9 months ago
nice tutorial...
httt0007 9 months ago
does this work with JCreator?
hydrokiller72 9 months ago
can this be maked on netbeans ????????????????
MrRafaStefan 10 months ago
@MrRafaStefan What ever Eclipse can make, NetBeans can make. NO EXCEPTIONS
klglange 10 months ago
@klglange ok ill test it now if can realy thanks ! :)
MrRafaStefan 10 months ago
Doesn't work... maybe it's because I'm using mp3?
12eebok 10 months ago
@12eebok You can simply convert it
xxxcoolboyxxx 10 months ago
@xxxcoolboyxxx It's fine, I installed the JLayer Jar which allows me to do exactly what I need -- without affecting the sound quality.
12eebok 10 months ago
Thank you so much, this video was a BIG help. The only issue I had was I had to place "String[ ] args" in "public static void (String[ ] args)". Otherwise it worked very well. thanks
ParcellRacing 11 months ago
This doesnt work its telling me that im missing something to be able to use this..
all the audio key words are red..
platano2007 11 months ago
How would you stop the loop? i have tried MGP.stop(loop); but that doesnt work... when i run the program it just keeps running until i close out of eclipse.
Thanks :)
johnthegr8 11 months ago
I'm using Java Ready to Program and i can't get the file to play Some1 help please.
1jathavan 11 months ago
thanks a lot! i've been trying to find out how to playback audio for a while, and everything but this failed.
thanks for ending my frustration and cursing :)
harangatang27 1 year ago
I use netbeans, can't play.
Justeenoster 1 year ago
please teach me how to stop that audio, guys
LaCrusNguyen 1 year ago
please teach me how to stop that audio, guys
LaCrusNguyen 1 year ago
@LaCrusNguyen A little late now, but it is what he mentioned he forget... the close operator:
object.setDefaultCloseOperation(JFrame.Exit_ON_CLOSE);
Now you can click the 'x' button and the program will exit.
anaik1 1 year ago
thx :D
KivivoimaFlash 1 year ago
You rock, my teacher is expecting us to put sound clips to our latest program but the book only tells us how to put sound to applets. fail xD
steaiii 1 year ago
damn your lips are kinda annoying -_-
nyc vid anyway
massmurderer02 1 year ago
im getting a error that says that audiostream and the other methods are not accesible due to the restriction on required library. Can anyone help?
BlitzOp 1 year ago 21
@BlitzOp I have same problem
mitchyc2012 1 year ago
@mitchyc2012
on the tool bar go to Windows -> Preferences -> Java -> Compiler -> Errors/Warnings. Change the forbidden references to "warning". This will allow it to run. For some reason I use pics or audio on my java.
BlitzOp 1 year ago
@BlitzOp Remove the JRE System Library, then add it again. It worked for me.
7BillowingClouds 3 months ago
thanks
enrichedd 1 year ago
convert your wav to au and it will work fine
oldmanKraven 1 year ago
it doesnt workkkkkk
patricio758 1 year ago
this tutorial only works on specific wav files. it will not work on mp3, mp4 and it will not work on high quality wav files.
if you want to make sure it works just try one of windows wav file
if you want to use mp3's try jmf player
malkisab 1 year ago
@malkisab For mp3's you could simply convert them in Audacity or some similar program.
Dayantos 1 year ago
hey i'am getting the error in this method( public static class Al implements ActionListener) its telling that its not override ABSTRACT METHOD,
please help..
mhdmirshad 1 year ago
it shows d click me button but it doesnt play.. can someone help me pls...
johnlevialoria 1 year ago
could someone tell me where should i put my audio file if am writing the code without any IDE (i mean manual coding)
saddamdon 1 year ago
it does not work!
ojbojcykelhoj 1 year ago
there was an error :could not create audio stream from an input stream
privartan1 1 year ago
Comment removed
CameraMan9258 1 year ago
java.io.IOException: could not create audio stream from input stream
TheYoosuf 1 year ago 2
@TheYoosuf Any help on that error!!
TheYoosuf 1 year ago
Hi I've got it working but I cant get it to stop looping :(, please please please could you help i would appreciate it sooooo much :)
doyoumind55 1 year ago
@doyoumind55
would u please send me your code i wrote it all identical to Mrjavahelp help but all i got was access restriction errors
deathinka 1 year ago
@deathinka do you mean warning messages? and what software are you using? warning messages are fine your program should still build fine
doyoumind55 1 year ago
awesome tutorial dude
but one quick question:
if im using JCreator, and the program cant find the file, is it because:
-The file is too big?
-Its an mp3 file?
-If i convert it to wav, would it work?
thnx for the video :)
MukaMoko 1 year ago
what's a good song for a puzzle game i'm making?
kidd093 1 year ago
does java only support wav files?
BlackMace28 1 year ago
i cannot use this in java 1.6 it says restricted access on audio player stream and data and that it will be removed in a future realease
RodonJarino 2 years ago
Thank you! This tutorial was very helpful. Except, how do you make it so that it only plays the clip once and not as a loop.
MrHeyAlan 2 years ago
scratch that, now I only have a problem with buttons 4-10 (i made a program with 10 buttons rather than 1)
and I get errors on the button(#).addActionListner (action(#) ());
saying that the action cannot be resolved as a type
any help?
gleboff 2 years ago
Not only will music not play on my first button, but for my second button I get this for the AudioData = MD;
"The local variable MD is never read"
Any help? thanks.
gleboff 2 years ago
Access restriction: The type AudioData is not accessible due to restriction on required library C:\Program Files\Java\jre6\lib\rt.jar
Why am I getting this error for everything involving AudioPlayer?
janneklouman 2 years ago
In eclipse do this: Window -> Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference (access rules) -> set it to 'Warnings'
schintus 2 years ago 13
@schintus Thanx ...it Worked :D
samriddha99 1 year ago
@schintus didn't work for me I am still getting a weird restriction error
anthropamorphic 7 months ago
Comment removed
janneklouman 2 years ago
Any one that knows how to stop the loop?
i have tried
AudioPlayer.player.stop (continuousaudiostream);
but it wont stop =/
joint08 2 years ago
Very helpful thanks!
Drace999 2 years ago
Great tutorial man, any one that uses netbeans?
i put the mp3 file in the same folder as the main file but the mp3 file still cant be found
joint08 2 years ago
You can put the full path of the file instead of just putting the file name. That way the program will know exactly where to look. For example you can put "C:/Users/My Documents/Safari2.mp3" instead of putting the file name
xxxcoolboyxxx 2 years ago
Thanks man, ill try that :)
joint08 2 years ago
@joint08 You can put it outside the src folder.
69elchupacabra69 2 years ago
I'm using netbeans.
ojbojcykelhoj 1 year ago
Thanks for EXCELENT tutorials.
A quick question(without trying).
If U delete the file(safari2), how come the program still run? Must be a catch error(file not found).
altisw5 2 years ago
I dont think a warning should matter to weather or not the program will work
xxxcoolboyxxx 2 years ago
awesome!
ryanharrison10 2 years ago