音乐播放脚本12错误

时间:2015-01-05 00:50:15

标签: java

这是我认为我遇到麻烦的部分:

public class AudioPlayer {
    //play the music
    AudioPlayer AP = new AudioPlayer([Optional Replay = true]);
    AP.playSong(signlink.findcachedir() + "Music/2.wav");
    //stop the music
    AP.Stop();
}

这是我得到的错误:

  

AudioPlayer.java:3:错误:')'预计AudioPlayer AP = new   AudioPlayer(可选Replay = true);                                            ^ AudioPlayer.java:3:错误:非法启动类型AudioPlayer AP = new AudioPlayer(可选重播   =真);                                                    ^ AudioPlayer.java:3:错误:预期AudioPlayer AP =新的AudioPlayer(可选   重播=真);                                                     ^ AudioPlayer.java:3:错误:';'预计AudioPlayer AP = new   AudioPlayer(可选Replay = true);                                                          ^ AudioPlayer.java:4:错误:预期   AP.playSong(signlink.findcachedir()+“Music / 2.wav”);              ^ AudioPlayer.java:4:错误:预期AP.playSong(signlink.findcachedir()+“Music / 2.wav”);                                    ^ AudioPlayer.java:4:错误:';'预期AP.playSong(signlink.findcachedir()+“Music / 2.wav”);                                     ^ AudioPlayer.java:4:错误:非法启动类型AP.playSong(signlink.findcachedir()+“Music / 2.wav”);                                       ^ AudioPlayer.java:4:错误:预期AP.playSong(signlink.findcachedir()+   “音乐/ 2.wav”);                                        ^ AudioPlayer.java:4:错误:';'预期AP.playSong(signlink.findcachedir()+“Music / 2.wav”);                                                      ^ AudioPlayer.java:6:错误:预期AP.Stop();          ^ AudioPlayer.java:6:错误:解析AP.Stop()时到达文件末尾;             ^ 12错误按任意键继续。 。 .`

有关正在发生的事情的任何想法?是什么导致错误,我该如何解决?

1 个答案:

答案 0 :(得分:-1)

尝试替换此行

AudioPlayer AP = new AudioPlayer([Optional Replay = true]);

这一个:

boolean optionalReplay = true;
AudioPlayer AP = new AudioPlayer(optionalReplay);

该计划并未理解此声明:[Optional Replay = true]。我给你的是更适合Java的语法。

仅供参考,我假设AudioPlayer构造函数接受布尔参数。但我可能会猜错你编写代码的方式。