SlideShare a Scribd company logo
Below are some exercises to practice your skills with sound and image manipulation. Make a
new scenario for a (very simple) MP3 player. Create an actor for a start button. Place an MP3 file
into the scenario's sound folder. Program it so that clicking the button starts playing the MP3
file. Clicking it while it is playing stops playing the file. Make sure the button image changes: It
should be the typical "play" triangle while the sound is not playing, and change to the usual
"pause" symbol (double vertical bars) when it is playing. Add a stop button. This button should
stop the sound. When you then press play again, the sound starts from the beginning (not from
the point where it was stopped). Make sure the play button's image changes approximately when
the sound is stopped. Add two buttons to change the volume up and down. Add a display that
shows the current volume. Add three buttons to select three different songs (which you must
place in your sounds folder).
Solution
import java.applet.Applet;
example 10.45 and 10.47 :-
import java.applet.AudioClip;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class sound extends Applet implemets ActionListener{
Button play,stop;
AudioClip clip;
private static final string PLAY = "PLAY";
private static final string STOP = "STOP";
public void init()
{
play= new Button();
play.setLabel(PLAY);
play.setActionCommand(PLAY);
play.addActionListener(this);
add(play);
stop= new Button();
stop.setLabel(STOP);
stop.setActionCommand(STOP);
stop.addActionListener(this);
add(stop);
audioclip = getAudioclip(getcodebase() ,"one.mp3");
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equlas(PLAY))
{
audioClip.PLAY();
}
elseif((e.getActionCommand().equlas(STOP))
{
audioClip.STOP();
};
else{
audioClip.STOP();
}`
}
}
exercise 10.48 :
import java.Windows.Forms;
import java.Runtime.InteropServices;
public class form1 extends form{
private const int APPCOMMAND_VOLUME_MUTE=53422;
private const int APPCOMMAND_VOLUME_UP=52222;
private const int APPCOMMAND_VOLUME_DOWN=23422;
private const int WM_APPCOMMAND = 345;;
public static extern Intptr send messageW(IntPtr, int Msg , IntPtr, wPara , Intptr, lparam);
public form1() {
InitializeComponent();
}
private final void mute_CLICK(object sender, EventArgs e) {
Form1.SendMessage(this.Handle , WM_APPCOMMAND , this.Handle,
((IntPtr)(APPCOMMAND_VOLUME_MUTE)));
}
private final void decvol_CLICK(object sender, EventArgs e) {
Form1.SendMessage(this.Handle , WM_APPCOMMAND , this.Handle,
((IntPtr)(APPCOMMAND_VOLUME_MUTE)));
}
private final void incvol_CLICK(object sender, EventArgs e) {
Form1.SendMessage(this.Handle , WM_APPCOMMAND , this.Handle,
((IntPtr)(APPCOMMAND_VOLUME_MUTE)));
}
EXRECISE 10.49:
ADD A DISPLAY THAT SHOWS CURRENT VOLUME :-
import javax.sound.sampled.FloatControl;
protected FloatControl {
system.out.println("value is "+float getValue());
}
Exercise 10.46:- change image on pressing the button
import java.util.*;
public class changeimage extends japanel implements ActionListener{
private static string[] images lists{ //keep the path for images location// like
images/0ne.jpeg.....}
//extend the first example program but in action listener palce the following code:-
image=new ImageIcon("images lists[1]);
//implement the same code in play button also

More Related Content

PPTX
Using final cut pro
KEY
openFrameworks 007 - sound
PPTX
Task 6 0.2
PPTX
Sound game maker explanations
PPTX
Print screens for final cut pro
PPTX
PPTX
Editing log
DOCX
Java termproject
Using final cut pro
openFrameworks 007 - sound
Task 6 0.2
Sound game maker explanations
Print screens for final cut pro
Editing log
Java termproject

Similar to Below are some exercises to practice your skills with sound and image.pdf (20)

PDF
BeepComp - Chiptune Creator - User's Guide (v0.2.2)
PDF
How to make renpy game maker for beginners .pdf
PPTX
Editing log
PPTX
Unit 73- Criteria 4: Programming Sounds Into a Video Game.
PPT
How To Create A Song Using Garage Band Without
PPTX
Post production (start)
DOCX
In the beginningAfter playing some songs and playing a cu.docx
PDF
Apple Garage Band
PPTX
Production Reflection
PPTX
Titling step by step
PPTX
MusicEngine for Unity/ADX2LE(English)
PDF
Digital Media Academy - Day 1
PDF
Premiere Pro: Green screen
PDF
The sounds of Android (Android Makers 2018)
PDF
Digital Media Academy - Day 2
PDF
Need help with this java project, as the methods are proving to be p.pdf
PDF
Ikitmovie Animation Software Tutorial
PDF
Work flow for adoboe primere element 9
PPT
Nerve Slide Show 04 19 2009 97 03
BeepComp - Chiptune Creator - User's Guide (v0.2.2)
How to make renpy game maker for beginners .pdf
Editing log
Unit 73- Criteria 4: Programming Sounds Into a Video Game.
How To Create A Song Using Garage Band Without
Post production (start)
In the beginningAfter playing some songs and playing a cu.docx
Apple Garage Band
Production Reflection
Titling step by step
MusicEngine for Unity/ADX2LE(English)
Digital Media Academy - Day 1
Premiere Pro: Green screen
The sounds of Android (Android Makers 2018)
Digital Media Academy - Day 2
Need help with this java project, as the methods are proving to be p.pdf
Ikitmovie Animation Software Tutorial
Work flow for adoboe primere element 9
Nerve Slide Show 04 19 2009 97 03

More from feelinggift (20)

PDF
A) Which of the following element is seen in all organic molecules Si.pdf
PDF
Given an ArrayList, write a Java method that returns a new ArrayList.pdf
PDF
Write an MSP430g2553 C program to drive a continually scrolling mess.pdf
PDF
Which of the following is NOT a financial measurement needed to see .pdf
PDF
Which process uses chemiosmosis A. Pyruvate oxidation B. Electron .pdf
PDF
What motives do corporate executives have that force them to embrace.pdf
PDF
when are business cases or project charters overkillSolutionP.pdf
PDF
True or False The Congressional Budget Office projects that approxi.pdf
PDF
Using the space provided compose an ESSAY concerning the following qu.pdf
PDF
We continually hear about interest groups in the news. Understanding.pdf
PDF
View transaction list Journal entry worksheet 6 9 The company receive.pdf
PDF
Physical security is a fundamental component of any secure infrastru.pdf
PDF
TrueFalse Verilog is case-insensitive TF Verilog has constructs.pdf
PDF
This is a homework assignment that I have for my Java coding class. .pdf
PDF
The Jannuschs operated Festival Foods, a busi- ness that served conc.pdf
PDF
The first thermodynamic law for a system of charged molecules in elec.pdf
PDF
show all of your work to arrive a final result Simple Interest Simpl.pdf
PDF
Terms from which students can chooseMacrophages; •Only one.pdf
PDF
Simulate the Stakeholder deliverable for the development of an onlin.pdf
PDF
I want to write this program in java.Write a simple airline ticket.pdf
A) Which of the following element is seen in all organic molecules Si.pdf
Given an ArrayList, write a Java method that returns a new ArrayList.pdf
Write an MSP430g2553 C program to drive a continually scrolling mess.pdf
Which of the following is NOT a financial measurement needed to see .pdf
Which process uses chemiosmosis A. Pyruvate oxidation B. Electron .pdf
What motives do corporate executives have that force them to embrace.pdf
when are business cases or project charters overkillSolutionP.pdf
True or False The Congressional Budget Office projects that approxi.pdf
Using the space provided compose an ESSAY concerning the following qu.pdf
We continually hear about interest groups in the news. Understanding.pdf
View transaction list Journal entry worksheet 6 9 The company receive.pdf
Physical security is a fundamental component of any secure infrastru.pdf
TrueFalse Verilog is case-insensitive TF Verilog has constructs.pdf
This is a homework assignment that I have for my Java coding class. .pdf
The Jannuschs operated Festival Foods, a busi- ness that served conc.pdf
The first thermodynamic law for a system of charged molecules in elec.pdf
show all of your work to arrive a final result Simple Interest Simpl.pdf
Terms from which students can chooseMacrophages; •Only one.pdf
Simulate the Stakeholder deliverable for the development of an onlin.pdf
I want to write this program in java.Write a simple airline ticket.pdf

Recently uploaded (20)

PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Institutional Correction lecture only . . .
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
GDM (1) (1).pptx small presentation for students
102 student loan defaulters named and shamed – Is someone you know on the list?
Microbial diseases, their pathogenesis and prophylaxis
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
FourierSeries-QuestionsWithAnswers(Part-A).pdf
01-Introduction-to-Information-Management.pdf
Chinmaya Tiranga quiz Grand Finale.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Institutional Correction lecture only . . .
O5-L3 Freight Transport Ops (International) V1.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Final Presentation General Medicine 03-08-2024.pptx
A systematic review of self-coping strategies used by university students to ...
202450812 BayCHI UCSC-SV 20250812 v17.pptx
GDM (1) (1).pptx small presentation for students

Below are some exercises to practice your skills with sound and image.pdf

  • 1. Below are some exercises to practice your skills with sound and image manipulation. Make a new scenario for a (very simple) MP3 player. Create an actor for a start button. Place an MP3 file into the scenario's sound folder. Program it so that clicking the button starts playing the MP3 file. Clicking it while it is playing stops playing the file. Make sure the button image changes: It should be the typical "play" triangle while the sound is not playing, and change to the usual "pause" symbol (double vertical bars) when it is playing. Add a stop button. This button should stop the sound. When you then press play again, the sound starts from the beginning (not from the point where it was stopped). Make sure the play button's image changes approximately when the sound is stopped. Add two buttons to change the volume up and down. Add a display that shows the current volume. Add three buttons to select three different songs (which you must place in your sounds folder). Solution import java.applet.Applet; example 10.45 and 10.47 :- import java.applet.AudioClip; import java.awt.Button; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class sound extends Applet implemets ActionListener{ Button play,stop; AudioClip clip; private static final string PLAY = "PLAY"; private static final string STOP = "STOP"; public void init() { play= new Button(); play.setLabel(PLAY); play.setActionCommand(PLAY); play.addActionListener(this); add(play); stop= new Button(); stop.setLabel(STOP); stop.setActionCommand(STOP); stop.addActionListener(this);
  • 2. add(stop); audioclip = getAudioclip(getcodebase() ,"one.mp3"); } public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equlas(PLAY)) { audioClip.PLAY(); } elseif((e.getActionCommand().equlas(STOP)) { audioClip.STOP(); }; else{ audioClip.STOP(); }` } } exercise 10.48 : import java.Windows.Forms; import java.Runtime.InteropServices; public class form1 extends form{ private const int APPCOMMAND_VOLUME_MUTE=53422; private const int APPCOMMAND_VOLUME_UP=52222; private const int APPCOMMAND_VOLUME_DOWN=23422; private const int WM_APPCOMMAND = 345;; public static extern Intptr send messageW(IntPtr, int Msg , IntPtr, wPara , Intptr, lparam); public form1() { InitializeComponent(); } private final void mute_CLICK(object sender, EventArgs e) { Form1.SendMessage(this.Handle , WM_APPCOMMAND , this.Handle, ((IntPtr)(APPCOMMAND_VOLUME_MUTE))); } private final void decvol_CLICK(object sender, EventArgs e) { Form1.SendMessage(this.Handle , WM_APPCOMMAND , this.Handle,
  • 3. ((IntPtr)(APPCOMMAND_VOLUME_MUTE))); } private final void incvol_CLICK(object sender, EventArgs e) { Form1.SendMessage(this.Handle , WM_APPCOMMAND , this.Handle, ((IntPtr)(APPCOMMAND_VOLUME_MUTE))); } EXRECISE 10.49: ADD A DISPLAY THAT SHOWS CURRENT VOLUME :- import javax.sound.sampled.FloatControl; protected FloatControl { system.out.println("value is "+float getValue()); } Exercise 10.46:- change image on pressing the button import java.util.*; public class changeimage extends japanel implements ActionListener{ private static string[] images lists{ //keep the path for images location// like images/0ne.jpeg.....} //extend the first example program but in action listener palce the following code:- image=new ImageIcon("images lists[1]); //implement the same code in play button also