Playing sound thread sync with other codes ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • desturrr
    New Member
    • Oct 2009
    • 18

    Playing sound thread sync with other codes ?

    Hello all,

    I have small sized mp3 files that i can play via Java using JLayerPlayer that takes the address of mp3 files , JLayerPlayer objects can be played creating threads and starting. The problem is when i have for example 9 sounds and i want it them to play in consecutively , so i put them in for loop like:

    for(int i=1;i<mainNotaL ist.size()+1;i+ +)
    {
    neyBox1.arrange NeyImage(mainNo taList.get(i-1));
    showNames(mainN otaList.get(i-1));
    txtAciklama.set Text(mainNotaLi st.get(i-1).getAciklama( ));

    Thread currentThread=n ew Thread(mainNota List.get(i-1).getSoundLaye r());
    porteImgs[i].activate();
    currentThread.s tart();
    try {
    currentThread.j oin();
    } catch (InterruptedExc eption ex) {
    Logger.getLogge r(Ney1View.clas s.getName()).lo g(Level.SEVERE, null, ex);
    }
    }

    This codes starts and plays the sound consecutively but
    this codes

    neyBox1.arrange NeyImage(mainNo taList.get(i-1));
    showNames(mainN otaList.get(i-1));
    txtAciklama.set Text(mainNotaLi st.get(i-1).getAciklama( ));

    are not being executed sync with the sound. they all are executed after all the sounds are played. How can i execute this codes first then play one sound, execute this codes play one sound...

    I am new to java and the project due is this week , Desperately need solution.
    Every suggestion helps. Thanks.
  • desturrr
    New Member
    • Oct 2009
    • 18

    #2
    Ok. I asked the question , finally i found the solution. The methods that i claim does not work such as

    neyBox1.arrange NeyImage(mainNo taList.get(i-1));
    showNames(mainN otaList.get(i-1));
    txtAciklama.set Text(mainNotaLi st.get(i-1).getAciklama( ));

    are all calling the paint() method. But paint threads for the sake of efficiency are being executed at last and at the same time, the solution is to use
    paintImmediatel y() for the whole frame so that threads do not go to the line of painting threads , instead being executed instantly... Thanks anyway :).

    Comment

    Working...