Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

implementing audio

Posted on 2003-11-04
6
Medium Priority
?
263 Views
Last Modified: 2013-11-23
For some reason my applet crashes when i try to implement audio
i get an error saying applet notinited

and when i open the java console it says:

java.lang.NullPointerException

      at java.applet.Applet.getCodeBase(Unknown Source)

      at WaterTankThread.<init>(WaterTankThread.java:46)

      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

iv implemented it like so....

........
import java.applet.AudioClip;

public class AudioTest extends Applet implements ActionListener
{
// DATA MEMBERS
      ..........
      
      //sounds
      AudioClip soundVar;
                ...................

public AudioTest()            
      {
            .............
            //register sounds
            soundVar = getAudioClip(getCodeBase(), "sounda.wav"); //if i comment this line the applet will run fine??
0
Comment
Question by:limubai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9683083
You cannot acces getCodeBase() fromm the applet ctor.

Just move your initialisation code into the applets init() method.
0
 

Author Comment

by:limubai
ID: 9683086
OOps, it should say....

java.lang.NullPointerException

     at java.applet.Applet.getCodeBase(Unknown Source)

     at AudioTest.<init>(AudioTest.java:46)

     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
0
 

Author Comment

by:limubai
ID: 9683093
i dont have an init method?
does that mean i must implement an init method just for audio?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 92

Accepted Solution

by:
objects earned 80 total points
ID: 9683124
It's nothing to do with audio. init() is a standard applet method that is called to perform applet initialization.
Before it is called codebase is not defined.

replace your ctor with this:

public void init()          
     {
          .............
          //register sounds
          soundVar = getAudioClip(getCodeBase(), "sounda.wav"); \
    }
http://java.sun.com/docs/books/tutorial/applet/index.html


0
 

Author Comment

by:limubai
ID: 9685264
Thanks for that objects
0
 
LVL 92

Expert Comment

by:objects
ID: 9690772
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question