0

私のコードで何が間違っていますか? SUN API に関する警告があります。将来のリリースで削除される可能性があります..

import java.io.*;
import java.net.*; 

 import sun.audio.AudioData;
 import sun.audio.AudioPlayer;
 import sun.audio.AudioStream;
 import sun.audio.ContinuousAudioDataStream;

AudioPlayer myBackgroundPlayer = AudioPlayer.player;
ContinuousAudioDataStream myLoop = null;
            //use a try block in case the file doesn't exist.
          try {

              AudioStream myBackgroundMusic = new AudioStream(new FileInputStream("Audio/loop2.wav"));
              AudioData myData = myBackgroundMusic.getData();
              myLoop = new ContinuousAudioDataStream(myData);
              }
              catch(Exception error) {JOptionPane.showMessageDialog(null, "Invalid file!");}

              //play background music.
              myBackgroundPlayer.start(myLoop);

このコードを実行すると、無効なファイルが表示されました..

4

0 に答える 0