Page 2 of 2 FirstFirst 12
Results 21 to 34 of 34
  1. #21
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Yes, this brings up a good point: You MUST call close from a different thread than the one that the player is running on.

    But again, have you checked your code to see that the player objects are the same? (not sure how many times I need to request this).

  2. #22
    ravjot28 is offline Member
    Join Date
    Jun 2008
    Posts
    87
    Rep Power
    0

    Default

    yes my Player instances are the same i have mentioned above already by my code

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

  4. #24
    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 ravjot28 View Post
    yes my Player instances are the same i have mentioned above already by my code
    I've reviewed some of your code posts above and sorry, but I don't believe you. If this code is from your program:

    Java Code:
        public void run()   // Parent Thread
        { 
            do
            {
                try
                {
                     System.out.println(thread.getName());
                     
                        FileInputStream s=new FileInputStream(son);
                        Player p=new Player(s);  // **** Player is declared inside of the try block! ****
                        p.play();
                        if((p.isComplete())||(!rav))
                        {
                            son=songs[pp[++i1]];
                        }
                    
                }catch(Exception song){}
               
            }while(true);
        }
    then the currently playing Player is local to the try block, and I see no way you that you can have a reference to it to call close on it. Again, you likely have reference problems but are not recognizing it. Again, the issue has little to do with threading.

  5. #25
    ravjot28 is offline Member
    Join Date
    Jun 2008
    Posts
    87
    Rep Power
    0

    Default

    now see i have a made a code temporary one in which i have placed a counter and i played the song at the same time after 10 clocks i called p.close();

    Now nothing happens the counter is continuos playing and even the song

    Java Code:
    public class NewClass
    {
        Player p=null;
        int ss=60;
        int timee=20;
        int i=0;
        public static void main(String args[]) throws FileNotFoundException, JavaLayerException
        {
            new NewClass().TextClock1();
            new NewClass().play();
        }
    
        void play() throws JavaLayerException, FileNotFoundException
        {
            p=new Player(new FileInputStream("D:\\Multimedia\\Music\\Songs\\xyz.mp3"));
            p.play();
            p.close();
        }
         public void TextClock1()
        {
            javax.swing.Timer t = new Timer(1000, new ClockListener());
            t.start();
        }
          class ClockListener implements ActionListener
        {
        	public void actionPerformed(ActionEvent e)
            {
               
                i++;
                if(timee==10)
                {
                    p.close();
                }
                System.out.println(i);
                
    
        	}
        }
    
    }

  6. #26
    ravjot28 is offline Member
    Join Date
    Jun 2008
    Posts
    87
    Rep Power
    0

    Default

    ok give me your email id i will send it to u

  7. #27
    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 ravjot28 View Post
    now see i have a made a code temporary one in which i have placed a counter and i played the song at the same time after 10 clocks i called p.close();

    Now nothing happens the counter is continuos playing and even the song

    Java Code:
    public class NewClass
    {
        Player p=null;
        int ss=60;
        int timee=20;
        int i=0;
        public static void main(String args[]) throws FileNotFoundException, JavaLayerException
        {
            new NewClass().TextClock1();
            new NewClass().play();
        }
    You've got a reference issue in this little snippet. Note that you're calling play and TextClock1 on two completely different NewClass instances. So you'll be calling close on a null Player instance from the TextClock1() method.

    And the best way to get your code to us is upload it in this thread in the forum.

    This snip doesn't have a background thread, so I'm not sure if this will work but what if you try:
    Java Code:
        NewClass newClass = new NewClass();
        newClass.TextClock1();
        newClass.play();
    Last edited by Fubarable; 03-02-2010 at 03:16 PM.

  8. #28
    ravjot28 is offline Member
    Join Date
    Jun 2008
    Posts
    87
    Rep Power
    0

    Default

    Hi here is my code kindly solve my problem i am desperate to solve it


    Thank you for helping

    kind regards
    Attached Files Attached Files

  9. #29
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,310
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by ravjot28 View Post
    Hi here is my code kindly solve my problem i am desperate to solve it


    Thank you for helping

    kind regards
    I googled for the documentation of that 'javazoom' stuff; this is for the Player.close() method: "Cloases this player. Any audio currently playing is stopped immediately." (typo is in the docs). If it doesn't work contact those javazoom guys and gals.

    kind regards,

    Jos

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

    Default

    It's not a Javazoom problem, it's not a thread problem, it's as I thought a reference problem pure and simple. To the OP, what effect do you think this will have on the currently playing MP3 object?:
    Java Code:
    try{new MP3().next();}
    Note to all, the next() method is where he has the close() method.

  11. #31
    ravjot28 is offline Member
    Join Date
    Jun 2008
    Posts
    87
    Rep Power
    0

    Default

    Can u explain me where is the problem i am not getting the problem please bare with me i totally confused

  12. #32
    ravjot28 is offline Member
    Join Date
    Jun 2008
    Posts
    87
    Rep Power
    0

    Default

    And sorry all as i was busy with some personal problems so i was not able to check the thread

    And i respect all and i thank all for giving me time

    I just want to stop the current song how can i do now you all have the code so kindly direct me to the location where i am going wrong and what should i insert so that the current song is stopped or paused

    Thank you

  13. #33
    ravjot28 is offline Member
    Join Date
    Jun 2008
    Posts
    87
    Rep Power
    0

    Default

    Thank You all i have finally got it thank you Fubarable thanx a lot

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

Page 2 of 2 FirstFirst 12

Similar Threads

  1. MultiThreading Problem
    By ravjot28 in forum New To Java
    Replies: 8
    Last Post: 03-02-2010, 12:23 PM
  2. Log 4j Multithreading
    By joe2010 in forum Threads and Synchronization
    Replies: 1
    Last Post: 01-31-2010, 03:48 AM
  3. problem using ObjectOutputStream in multithreading
    By sanjeevbindroo in forum Networking
    Replies: 3
    Last Post: 10-15-2009, 08:00 AM
  4. multithreading
    By shilpa.krishna in forum New To Java
    Replies: 2
    Last Post: 06-27-2008, 04:18 PM

Posting Permissions

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