🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #11

Re: Applet play midi

#11
From: rwilkman
Date: Wed, 12 Jan 2000 00:00
91 lines
3800 bytes
Look in your Java console; there may be an error (like an out of memory
exception).

Why not use (and reuse) a single AudioClip object instead?

-Rich

"Yuan-rui Liang (�礸��)" wrote:
> 
> Hello there:
> 
> I want to use an Applet to play many different midi files,
> but it can only play the first eight midi files.
> I don't know either the other midi files were not loaded nor the applet
> can't play those after 8th midi file.
> 
> Thank you for spanding time solving my question.
> 
> My code is shown below:
> 
> import java.awt.*;
> import java.awt.event.*;
> import java.applet.*;
> 
> public class Applet1 extends Applet implements ActionListener{
>   Button button1 = new Button("button1");
>   Button button2 = new Button("button2");
>   Button button3 = new Button("button3");
>   Button button4 = new Button("button4");
>   Button button5 = new Button("button5");
>   Button button6 = new Button("button6");
>   Button button7 = new Button("button7");
>   Button button8 = new Button("button8");
>   Button button9 = new Button("button9");
>   Button button10 = new Button("button10");
>   AudioClip c1;
>   AudioClip c2;
>   AudioClip c3;
>   AudioClip c4;
>   AudioClip c5;
>   AudioClip c6;
>   AudioClip c7;
>   AudioClip c8;
>   AudioClip c9;
>   AudioClip c10;
> 
>   public void init() {
>     add(button1);  button1.addActionListener(this);
>     add(button2);  button2.addActionListener(this);
>     add(button3);  button3.addActionListener(this);
>     add(button4);  button4.addActionListener(this);
>     add(button5);  button5.addActionListener(this);
>     add(button6);  button6.addActionListener(this);
>     add(button7);  button7.addActionListener(this);
>     add(button8);  button8.addActionListener(this);
>     add(button9);  button9.addActionListener(this);
>     add(button10);  button10.addActionListener(this);
>     c1=getAudioClip(getCodeBase(),"audio/C4.mid");
>     c2=getAudioClip(getCodeBase(),"audio/Cs4.mid");
>     c3=getAudioClip(getCodeBase(),"audio/D4.mid");
>     c4=getAudioClip(getCodeBase(),"audio/Ds4.mid");
>     c5=getAudioClip(getCodeBase(),"audio/E4.mid");
>     c6=getAudioClip(getCodeBase(),"audio/F4.mid");
>     c7=getAudioClip(getCodeBase(),"audio/Fs4.mid");
>     c8=getAudioClip(getCodeBase(),"audio/G4.mid");
>     c9=getAudioClip(getCodeBase(),"audio/Gs4.mid");
>     c10=getAudioClip(getCodeBase(),"audio/A4.mid");
>   }
> 
>   public void actionPerformed(ActionEvent e) {
>     Object source=e.getSource();
>     if(source==button1) c1.play();
>     else if(source==button2) c2.play();
>     else if(source==button3) c3.play();
>     else if(source==button4) c4.play();
>     else if(source==button5) c5.play();
>     else if(source==button6) c6.play();
>     else if(source==button7) c7.play();
>     else if(source==button8) c8.play();
>     else if(source==button9) c9.play();
>     else if(source==button10) c10.play();
>   }
> }

-- 
=====
Rich Wilkman
Senior Quality Assurance Engineer
JBuilder Team

If you are reading this from a newsgroup post, don't send mail.
Technical Details
Message-ID: <387CAE06.1FB65675@inprise.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <387C842A.FEADDE07@mis.ttu.edu.tw>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: ff01d,daad335b141012a4
X-Google-Attributes: gidff01d,public
X-Google-Thread: f74b3,daad335b141012a4
X-Google-Attributes: gidf74b3,public
From: rwilkman <rwilkman@inprise.com>
Subject: Re: Applet play midi
Date: 2000/01/12
Message-ID: <387CAE06.1FB65675@inprise.com>
X-Deja-AN: 571693220
Content-Transfer-Encoding: 8bit
References: <387C842A.FEADDE07@mis.ttu.edu.tw>
X-Accept-Language: en
Content-Type: text/plain; charset=iso-8859-1
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language,borland.public.jbuilder.applet-issues