?
Solved

implementing audio

Posted on 2003-11-04
6
Medium Priority
?
247 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month13 days, 6 hours left to enroll

800 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