Home Can audio be implemented in a static nested class?
Reply: 0

Can audio be implemented in a static nested class?

user2420
1#
user2420 Published in July 21, 2018, 9:55 am

So I've been trying to implement this audio into my main class. My main class contains other methods which I will not include in order to prevent my post from being too long. I think the code is going wrong because of out.audio audio = new out.audio (); because I either placed it in the wrong method or I'm not using the right variables. I'm still very much a beginner coder so I'm already kinda confused with what's going on in my code. What I do know though is that running just the audio class alone (not nested) works.

Am I formatting my nested class correctly and is it possible to nest audio?

import java.awt.*;
import hsa.Console;
import java.awt.image.*;
import java.util.Random;
import sun.audio.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
class out implements ImageObserver
{
//lots of code and other methods here so I'm going to leave it out
public static class audio extends Thread
{
    out.audio audio = new out.audio ();
    public void run ()
    {
        while (true)
        {
            AudioPlayer MGP = AudioPlayer.player;
            AudioStream BGM;
            AudioData MD;

            ContinuousAudioDataStream loop = null;

            try
            {
                InputStream test = new FileInputStream ("Music long.au");
                BGM = new AudioStream (test);
                AudioPlayer.player.start (BGM);
                //MD = BGM.getData();
                //loop = new ContinuousAudioDataStream(MD);

            }
            catch (FileNotFoundException e)
            {
                System.out.print (e.toString ());
            }
            catch (IOException error)
            {
                System.out.print (error.toString ());
            }
            MGP.start (loop);
            try
            {
                Thread.sleep (200000);
            }
            catch (InterruptedException ie)
            {
            }
            try
            {
                Thread.sleep (1500);
            }
            catch (InterruptedException ie)
            {
            }
        }
    }
    public static void main (String[] args)
    {
        c = new Console ();
        audio t1 = new audio ();
        t1.start ();
        for (;;)
        {
            c.println ("");
            break;
        }

    } // main method
} // audio class
} //out class
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.393168 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO