开发者

My app throws 'java.io.IOException: could not create AudioData object'?

HI

I am trying to play an audio file in my Java application:

here is the code:

开发者_C百科
public static void music() 
    {       


  AudioPlayer MGP = AudioPlayer.player;
     AudioStream BGM;
     AudioData MD;

     ContinuousAudioDataStream loop = null;

     try
     {
      BGM = new AudioStream(new FileInputStream("\\BattleShip\\battle.wav"));
      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);

    }

I have no idea what this exception means or if it is even finding the wav file im trying to play

java.io.IOException: could not create AudioData object

thanks


Thank got it working. Changed the code to:

public static void music() 
    {       


        AudioPlayer MGP = AudioPlayer.player;
        AudioStream BGM;
        AudioData MD;

        ContinuousAudioDataStream loop = null;

        try
        {
            InputStream test = new FileInputStream("./battle.wav");
            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);

    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜