473,394 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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<mainNotaList.size()+1;i++)
{
neyBox1.arrangeNeyImage(mainNotaList.get(i-1));
showNames(mainNotaList.get(i-1));
txtAciklama.setText(mainNotaList.get(i-1).getAciklama());

Thread currentThread=new Thread(mainNotaList.get(i-1).getSoundLayer());
porteImgs[i].activate();
currentThread.start();
try {
currentThread.join();
} catch (InterruptedException ex) {
Logger.getLogger(Ney1View.class.getName()).log(Lev el.SEVERE, null, ex);
}
}

This codes starts and plays the sound consecutively but
this codes

neyBox1.arrangeNeyImage(mainNotaList.get(i-1));
showNames(mainNotaList.get(i-1));
txtAciklama.setText(mainNotaList.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.
Dec 24 '09 #1

✓ answered by desturrr

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

neyBox1.arrangeNeyImage(mainNotaList.get(i-1));
showNames(mainNotaList.get(i-1));
txtAciklama.setText(mainNotaList.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
paintImmediately() for the whole frame so that threads do not go to the line of painting threads , instead being executed instantly... Thanks anyway :).

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

neyBox1.arrangeNeyImage(mainNotaList.get(i-1));
showNames(mainNotaList.get(i-1));
txtAciklama.setText(mainNotaList.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
paintImmediately() for the whole frame so that threads do not go to the line of painting threads , instead being executed instantly... Thanks anyway :).
Dec 25 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Brian Basquille | last post by:
Hello all, What is the syntax for simply playing a WAV file in your program? Am learning VB and have two VB books but don't wanna root through them to find the code. Any help would be much...
1
by: Peter Schmitz | last post by:
Hi, I'm just trying to play a *.wav file, making use of the unmanaged function "sndPlaySoundA" in winmm.dll, but I still got one question: How can I avoid, that the sound file itself has to be...
2
by: Dave | last post by:
Hi, I am writing a c# application that using a directshow to play file and display it on my C# gui, its work just fine but when i try to open another thread in my c# application the file stop...
7
by: Lee Moody | last post by:
I just want quick and easy way to play a .wav file out the standard sound device. It could even be as simple as activating a sound assigned to an existing windows sound event. Any suggestions?...
5
by: jzlondon | last post by:
Hi, I have a question that I wonder if someone might be able to help me with... I have an application which handles real-time financial data from a third party source. The data comes in via...
4
by: fAnSKyer/C# newbie | last post by:
I am using winmm.dll and I found that I can't just suspend it and resume it? What should I do? Any better idea? Should I use thread? and thread.suspend will work? Thanks
4
by: gazza67 | last post by:
Hi, Does anyone know how to check for when a sound has finished playing? I am currently using the SoundPlayer, there doesnt seem to be any event for this - am I missing something? Gary
5
by: gazza67 | last post by:
Hi, Does anyone know how to check for when a sound has finished playing? I am currently using the SoundPlayer, there doesnt seem to be any event for this - am I missing something? Gary
3
by: Jack | last post by:
Hi, I'm writing a simple wav player (like winamp) and using the SoundPlayer class in c# 2005. Using winform buttons, I can begin playing the sound and stop half-way through the sound using:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.