audio applet or swing based application to play, pause and stop options
#1

[attachment=6181]
audio applet or swing based application to play, pause and stop options

• An applet is created. An applet will show three buttons-play, loop and stop.
• Whenever user clicks on play button an audio file with .wav extension starts playing.
• Whenever user clicks on loop button, same audio file will be played again and again.
• User can click on stop button to stop the audio file.

SOURCE CODE

import java.io.*;
import java.sql.*;
import javax.swing.*;
import javax.media.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class Audio extends JFrame implements ActionListener
{
Player player;
Component center;
Component south;
File f;
JButton jb1,jb2,jb3;
Container c;
public static void main(String[] args)
{
Audio vi=new Audio ();
}
Audio ()
{
jb1 = new JButton("Play");
jb2 = new JButton("Loop");
jb3 = new JButton("Stop");
c = getContentPane();
c.setLayout(new FlowLayout());
c.add(jb1);
c.add(jb2);
c.add(jb3);
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
setSize(300,300);
try
{
f =new File("D:/Devendra/Pracs/Multimedia/2.mp3");
try
{
load(f);
}
catch (Exception e)
{
System.out.println(e);
}
pack();
setVisible(true);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void load(final File file) throws Exception
{
URL url = file.toURL();
if (player != null)
{
player.stop();
}
player = Manager.createPlayer(url);
ControllerListener listener = new ControllerAdapter()
{
public void realizeComplete(RealizeCompleteEvent event)
{
Component vc = player.getVisualComponent();
if (vc != null)
{
c.add(vc,BorderLayout.CENTER);
center = vc;
}
else
{
if (center != null)
{
c.remove(center);
c.validate();
}
}
Component cpc = player.getControlPanelComponent();
if (cpc != null)
{
c.add(cpc,BorderLayout.SOUTH);
south = cpc;
}
else
{
if (south != null)
{
c.remove(south);
c.validate();
}
}
pack();
setTitle(file.getName());
}
};
player.addControllerListener(listener);
}

public void actionPerformed(ActionEvent ae)
{
if (ae.getSource() == jb1)
{
player.start();
}
if (ae.getSource() == jb2)
{
player.stop();
player.start();
}
if (ae.getSource() == jb3)
{
player.stop();
}
}
}


OUTPUT


Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: free online kids educational games to play, anchoring script for role play, mba notes on options, my play city transformers, the best student loan options, bangalakkhi lottery play in 29 01 16, play jqk result today**hi*,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Messages In This Thread
audio applet or swing based application to play, pause and stop options - by project report helper - 15-10-2010, 03:03 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  Service-Oriented Architecture for Weaponry and Battle Command and Control Systems in 1 1,090 15-02-2017, 03:40 PM
Last Post: jaseela123d
  Developing a web application to transfer image and patient information project report maker 2 3,703 21-03-2014, 01:44 AM
Last Post: MichaelPn
  Online Application For The Training and Placement Dept. Of The College. Electrical Fan 16 9,699 13-03-2014, 05:46 PM
Last Post: computer topic
  ONLINE MISSING VEHICLE TRACKING APPLICATION FOR POLICE DEPARTMENT seminar class 3 4,713 17-10-2013, 07:54 PM
Last Post: Guest
  Embedded Linux Based GLCD application development seminar surveyer 1 1,918 17-12-2012, 02:32 PM
Last Post: seminar details
Wink Implementation of a simple device mediation application of a Network Management Syste computer science crazy 2 2,194 06-12-2012, 01:57 PM
Last Post: seminar details
  application projects in java and vb.net (titles and topics) project topics 1 5,507 28-11-2012, 01:11 PM
Last Post: seminar details
  application project topics electronics seminars 1 7,420 28-11-2012, 01:11 PM
Last Post: seminar details
  Audio Steganography project topics 3 6,596 10-11-2012, 11:58 AM
Last Post: seminar details
  PREVENTION OF SQL INJECTION AND DATA THEFTS USING DIVIDE AND CONQUER APPROACH seminar presentation 3 4,215 24-10-2012, 01:09 PM
Last Post: seminar details

Forum Jump: