Gary Milne Active Member Licensed User Longtime User Oct 21, 2014 #1 I have a need to play some tones whilst the user is touching the screen. To get the UI to continue to respond whilst the tones play I need to use a separate thread. Well, If I implement it as inline code it all works as expected. When I package it into a class the tone does not play. If I change the class to play on the same thread then it works (but then the UI suffers) What is it about putting the thread call into a class that causes it not to work and is there something that can be done about it. Grateful for any responses.
I have a need to play some tones whilst the user is touching the screen. To get the UI to continue to respond whilst the tones play I need to use a separate thread. Well, If I implement it as inline code it all works as expected. When I package it into a class the tone does not play. If I change the class to play on the same thread then it works (but then the UI suffers) What is it about putting the thread call into a class that causes it not to work and is there something that can be done about it. Grateful for any responses.
Erel B4X founder Staff member Licensed User Longtime User Oct 22, 2014 #2 You don't need to create another thread for this. Both MediaPlayer and SoundPool play the sound file in the background. Upvote 0
You don't need to create another thread for this. Both MediaPlayer and SoundPool play the sound file in the background.
Gary Milne Active Member Licensed User Longtime User Oct 22, 2014 #3 I was using the AudioTrack library from this sample (http://www.b4x.com/android/forum/threads/audiotrack.14007/) which was using the same thread as I could not alter the screen controls whilst the sound was playing. I switched to using the sound library and that is working as a substitute. Still a good question though as to why placing the thread in a calss caused it to not work. Upvote 0
I was using the AudioTrack library from this sample (http://www.b4x.com/android/forum/threads/audiotrack.14007/) which was using the same thread as I could not alter the screen controls whilst the sound was playing. I switched to using the sound library and that is working as a substitute. Still a good question though as to why placing the thread in a calss caused it to not work.