开发者

Problem with multiple instances of a function

I have made a music quiz similar to the one in the iPod, everything runs perfect until my program calls a class MP3 ( http://pastebin.com/d52fe24ce ) to stop with the function close(). The problem in my case is that the 开发者_开发技巧MP3 is not "instantiated" when it is called. I am not sure but I think this is because the player I created is not null (see Main.java http://pastebin.com/d32ef2c06 around row 261), although there is actually no "instance" of the player... Anyone have any idea how I can make the player close the stream?


In line 283, you say:

 MP3 player = new MP3...

Here, you create a new local variable. Remove the first "MP3" so the new player gets assigned to the field player:

player = new MP3...


Line 283:

MP3 player = new MP3(((SongQuestion)question).getSongPath());

should be:

player = new MP3(((SongQuestion)question).getSongPath());

This uses the instance level MP3 player. What you are doing now creates a new local MP3 player that masks the instance level one.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜