Page 2 of 2 FirstFirst 12
Results 21 to 37 of 37
  1. #21
    Crathes is offline Member
    Join Date
    May 2011
    Posts
    20
    Rep Power
    0

    Default

    I think only once.
    first I have the public class:

    public class oppg2vaar2011Design extends JFrame implements ActionListener{

    then i have this:

    public oppg2vaar2011Design() {

    and later i make it visible with this:
    Java Code:
    public static void main(String[] args) {
    		oppg2vaar2011Design app = new oppg2vaar2011Design();
    		app.setVisible(true);

  2. #22
    Crathes is offline Member
    Join Date
    May 2011
    Posts
    20
    Rep Power
    0

    Default

    I have been checking the code, but i cant find anything wrong.

    I tried removing stopthread.start();
    This eliminated the error message, but it the playthread.interrupt() doesn't seem to do anything. Am doing the interrupt wrong?

  3. #23
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    I don't know as it's a bit of code and code I can't run. Until someone smarter comes here, you will likely want to simplify and isolate to try to get to the root of the problem.

  4. #24
    Crathes is offline Member
    Join Date
    May 2011
    Posts
    20
    Rep Power
    0

    Default

    Thanks for trying :)
    What do you mean with code you cant run?

    I don't really know how i can simplify it. I need the threads because i have to be able to do press buttons while the program is doing something, and i think the threads are the source of the problem.

  5. #25
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Crathes View Post
    Thanks for trying :)
    What do you mean with code you cant run?

    I don't really know how i can simplify it. I need the threads because i have to be able to do press buttons while the program is doing something, and i think the threads are the source of the problem.
    Your code depends on the AdvancedPlayer class and outside resources that I don't have access to including images and such.

  6. #26
    Crathes is offline Member
    Join Date
    May 2011
    Posts
    20
    Rep Power
    0

    Default

    Its not hard to get, if you want to try. link

  7. #27
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    392
    Rep Power
    4

    Default

    Try adding a "System.out.println(player)" just before you execute the "player.stop()". That will tell you if player really is null, or if there's something else fishy around.

  8. #28
    Crathes is offline Member
    Join Date
    May 2011
    Posts
    20
    Rep Power
    0

    Default

    This is the message i get from System.out.println(player):
    javazoom.jl.player.advanced.AdvancedPlayer@ 5d6d2633
    Last edited by Crathes; 05-08-2011 at 01:09 AM.

  9. #29
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    392
    Rep Power
    4

    Default

    That means that it's not player that is null; thus it's something else that's throwing the nullpointerexception. Try putting another System.out.println("stuff" right after the player.stop() line. If that one fires, then it's definitely not that line. Otherwise... I assume that AdvancedPlayer isn't something you've written yourself?

  10. #30
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    392
    Rep Power
    4

    Default

    Looking closer at the stacktrace, I'm starting to lean more and more towards something in AdvancedPlayer throwing a NullPointerException. Perhaps it is intended and indicative of something specific? Read through the docs to see if there are any hints in there about why it throws it.

  11. #31
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Toll View Post
    Looking closer at the stacktrace, I'm starting to lean more and more towards something in AdvancedPlayer throwing a NullPointerException. Perhaps it is intended and indicative of something specific? Read through the docs to see if there are any hints in there about why it throws it.

    Like I said -- wait for someone smarter to come along, and here he is. :)

  12. #32
    Crathes is offline Member
    Join Date
    May 2011
    Posts
    20
    Rep Power
    0

    Default

    Quote Originally Posted by Toll View Post
    That means that it's not player that is null; thus it's something else that's throwing the nullpointerexception. Try putting another System.out.println("stuff" right after the player.stop() line. If that one fires, then it's definitely not that line. Otherwise... I assume that AdvancedPlayer isn't something you've written yourself?
    When i put System.out.println("stuff") right after player.stop() i get nothing.
    When i put it in the if statement for the stop button, right after trying to stop and start the two threads it writes out "stuff".

    No, the advanced player is an external library i downloaded from Javazoom.net.

    Quote Originally Posted by Toll View Post
    Looking closer at the stacktrace, I'm starting to lean more and more towards something in AdvancedPlayer throwing a NullPointerException. Perhaps it is intended and indicative of something specific? Read through the docs to see if there are any hints in there about why it throws it.
    I cannot find any information about AdvancedPlayer throwing NullPointerException. The only Exception they have information on is the JavaLayerException.

  13. #33
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    392
    Rep Power
    4

    Default

    Well, right now everything points towards something within AdvancedPlayer throwing a NullPointerException. The documentation doesn't help much either, unfortunately.. I can far from guarantee that it will help, but try adding a PlaybackListener to the player. It could be that it doesn't check if the listener is null when trying to stop the player. If that doesn't work... well, can't help much.

  14. #34
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    392
    Rep Power
    4

    Default

    Looking through the code, it's no wonder you get a NPE there without a listener. This is all the code that is executed in the stop() function:
    Java Code:
    	public void stop()
    	{
    		listener.playbackFinished(createEvent(PlaybackEvent.STOPPED));
    		close();
    	}
    So yeah... Add a listener and the NPE should go away. Hopefully. You can also try calling close() instead of stop().

  15. #35
    Crathes is offline Member
    Join Date
    May 2011
    Posts
    20
    Rep Power
    0

    Default

    EDIT: never mind

  16. #36
    Crathes is offline Member
    Join Date
    May 2011
    Posts
    20
    Rep Power
    0

    Default

    When i added the playbackListener nothing new happened. I'm not sure if i did it correctly though. I'll update the code in OP to include it.

    When i say player.close() instead of player.stop(), the player actually stops. I hope i will be able to use this method in a pause button as well.

  17. #37
    Crathes is offline Member
    Join Date
    May 2011
    Posts
    20
    Rep Power
    0

    Default

    I have spent several hours trying to figure out how to do a button with a pause function for my mp3 player now, and I do not have any clue. Do any of you guys have any ideas?

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Wav player not playing
    By RightGoodEnt in forum CLDC and MIDP
    Replies: 0
    Last Post: 02-13-2011, 04:23 PM
  2. JMF player.setSource
    By lambi in forum Advanced Java
    Replies: 2
    Last Post: 02-22-2010, 01:09 PM
  3. SWT Flash Player
    By forthe in forum SWT / JFace
    Replies: 0
    Last Post: 07-29-2008, 08:48 AM
  4. mp3 player applet
    By willemjav in forum Java Applets
    Replies: 0
    Last Post: 05-20-2008, 01:16 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •