Results 21 to 37 of 37
Thread: Help with Mp3 player
- 05-07-2011, 08:06 PM #21
Member
- Join Date
- May 2011
- Posts
- 20
- Rep Power
- 0
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);
- 05-07-2011, 08:59 PM #22
Member
- Join Date
- May 2011
- Posts
- 20
- Rep Power
- 0
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?
-
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.
- 05-07-2011, 09:19 PM #24
Member
- Join Date
- May 2011
- Posts
- 20
- Rep Power
- 0
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.
-
- 05-07-2011, 09:50 PM #26
Member
- Join Date
- May 2011
- Posts
- 20
- Rep Power
- 0
Its not hard to get, if you want to try. link
- 05-07-2011, 11:37 PM #27
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.
- 05-08-2011, 01:07 AM #28
Member
- Join Date
- May 2011
- Posts
- 20
- Rep Power
- 0
This is the message i get from System.out.println(player):
javazoom.jl.player.advanced.AdvancedPlayer@ 5d6d2633Last edited by Crathes; 05-08-2011 at 01:09 AM.
- 05-08-2011, 01:14 AM #29
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?
- 05-08-2011, 01:42 AM #30
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.
-
- 05-08-2011, 10:55 AM #32
Member
- Join Date
- May 2011
- Posts
- 20
- Rep Power
- 0
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.
I cannot find any information about AdvancedPlayer throwing NullPointerException. The only Exception they have information on is the JavaLayerException.
- 05-08-2011, 11:04 AM #33
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.
- 05-08-2011, 11:11 AM #34
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:
So yeah... Add a listener and the NPE should go away. Hopefully. You can also try calling close() instead of stop().Java Code:public void stop() { listener.playbackFinished(createEvent(PlaybackEvent.STOPPED)); close(); }
- 05-08-2011, 11:21 AM #35
Member
- Join Date
- May 2011
- Posts
- 20
- Rep Power
- 0
EDIT: never mind
- 05-08-2011, 11:29 AM #36
Member
- Join Date
- May 2011
- Posts
- 20
- Rep Power
- 0
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.
- 05-15-2011, 11:50 PM #37
Member
- Join Date
- May 2011
- Posts
- 20
- Rep Power
- 0
Similar Threads
-
Wav player not playing
By RightGoodEnt in forum CLDC and MIDPReplies: 0Last Post: 02-13-2011, 04:23 PM -
JMF player.setSource
By lambi in forum Advanced JavaReplies: 2Last Post: 02-22-2010, 01:09 PM -
SWT Flash Player
By forthe in forum SWT / JFaceReplies: 0Last Post: 07-29-2008, 08:48 AM -
mp3 player applet
By willemjav in forum Java AppletsReplies: 0Last Post: 05-20-2008, 01:16 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks