how do i make to play sound in my program after turning on i tryed some codes but the song doesnt start ...
I maked the song into 10 secounds but still cannot start.
anyone help ?

be more clear about what format you are trying to play.
if it's just a .wav file, you don't need any additional libraries, but, if you want (for instance) to play .mp3 files, you should note that they are not supported by core Java.

in order to play those, you'll need to add an additional library or framework that can help you out.
my first thoughts would be the Java Media Framework api, or JMF for short, or JavaZoom's JLayer library.

personally, when I once tried to write my own mp3 player, I preferred JLayer over JMF. JMF hadn't been updated for quite a while, and it was a bit more messy to set everything up. besides, JLayer is pretty easy to work with, if you go through the documentation and example(s) they offer.

Thanks in advice i tryed with (.wav) and worked but my project is to drag it in the program or upload it and just play/stop from there, yeah it is like small player, so if you can give me some exsample how to start with that draging/uploading and stop/play.
Thanks :)

or just add some songs from the code into the program and play it from there ...

Edited 3 Years Ago by StefanRafa0

I don't think that 'll do it. he's trying to drag something from his windows explorer into his java environment.
don't think awt has much notice about what files he has stored locally.

just show me how to add the songs into the JFrame and thats all no need drag and stuff just to show the name of the song which is playing at the moment ...

you can always use a JFileChooser to add them, just store them in a tracklist, and for the rest, just consider your tracks as Objects, with instance members:
String title
String artist
File localFile
...

This article has been dead for over six months. Start a new discussion instead.