Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-30-2008, 06:02 PM
Member
 
Join Date: May 2008
Posts: 3
iliana is on a distinguished road
how can I play an mp3 file in java?
hey, I've written something in another thread but it is a little old so...I hope you see it here..


I want to play an mp3 file and the code in eclipse is something like the following ... I see the interface but it can't be played...

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;

public class AudioFilee extends JFrame {

public AudioFilee() {

setTitle("Music File");
setSize(300, 400);

JPanel jp1 = new JPanel();
JPanel jp2 = new JPanel();


JButton s= new JButton("STOP");
JButton p= new JButton("PLAY");
JLabel j1 = new JLabel("MusicFile");
String[] musicfiles={"workspace/eclipse/Audio/asdf.mp3","asd.mp3"};
JComboBox musiclist=new JComboBox(musicfiles);
musiclist.setSelectedIndex(1);


jp1.add(j1);
jp1.add(musiclist);

jp2.add(s);
jp2.add(p);



JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
true, jp1, jp2);

splitPane.setOneTouchExpandable(true);
getContentPane().add(splitPane);

}
public static void main(String[] args) {

AudioFilee sp = new AudioFilee();
sp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sp.setVisible(true);

}
}

Do you have any suggestion? Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-30-2008, 08:32 PM
Member
 
Join Date: May 2008
Posts: 26
Master Zero is on a distinguished road
You need to implement the action listener class and create the action performed method for your buttons, as event handlers. The link below shows you how to play audio files in java.

Code:
docs.rinet.ru/JaTricks/ch4.htm
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to play movie using java sithara New To Java 1 02-08-2008 06:52 AM
play() and mp3 willemjav Advanced Java 3 12-23-2007 03:50 PM
Make sound play in a java application lenny AWT / Swing 2 08-13-2007 12:45 PM
how to play MIDI in java application? oregon Advanced Java 1 08-07-2007 03:26 AM
How to play video files in Java Hasan Advanced Java 1 05-31-2007 06:25 PM


All times are GMT +3. The time now is 03:00 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org