i am done with almost all the functions of a simple mp3 player , i am trying to make , i 'm stuck with pause function, i dont know , i was thinking of creating a separate thread for it...

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
song_name=(String) jTable2.getValueAt(jTable2.getSelectedRow(), 0);
if(count>0)
{
    clip.stop();
clip=  getAudioClip(getCodeBase(), "songs/" + song_name+".MP3");
        clip.play();
}
else
{
    clip=getAudioClip(getCodeBase(),"songs/"+song_name+".MP3");
    clip.play();
}
count++;
        jLabel3.setText("chanegd");  
    }                                        

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
clip.stop();
int x=jTable2.getSelectedRow();
x++;
jTable2.changeSelection(x,0,false,true);
song_name=(String)jTable2.getValueAt(x,0); 
clip=getAudioClip(getCodeBase(),"songs/"+song_name+".MP3");
clip.play();
    }                                        

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
       
        clip.stop();    // TODO add your handling code here:
    }                                        

    private void jButton5MouseClicked(java.awt.event.MouseEvent evt) {                                      

    }                                     

    private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {                                     
        jLabel3.setText(jTable2.getValueAt(jTable2.getSelectedRow(), 0) + "");
 jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // TODO add your handling code here:
    }

Recommended Answers

All 5 Replies

and how did you create the clip?

I just took the references if Jtable names too play the song at the click of the button!!!
well clip i have used it as a object of the class AudioClip and i have done AudioClip cilip globally!

Have you read about JMF? There are a lot of explanations of why it is difficult to do things such as writing pause methods for audio clips. And there is guidance to how to accomplish doing it if you really decide to take on the challenge.

Actually no , i was thinking on waking and notifying the thread !! wudn't it work?

i understood your problem.i have already experienced it but some difference in programable stratagy try this way
first add keyboard interface to your code
then select a key which you want use as an pause method
then implement a logic such as whenever you pressed that button first time the clip will be stopped for the second time running.Try it sure it will solve your problem efficiently

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.