Syncro sound playback

peacemaker

Expert
Licensed User
Longtime User
Hi, all

Possible now playback possibility of several audio files, but strickly one by one ?
 

peacemaker

Expert
Licensed User
Longtime User
Hmm, think this code should be OK ? If MediaPlayer already initialized.

Sub PlaySound (Dir,FileName)
Do While mp.IsPlaying
DoEvents
Loop
mp.Load(Dir, FileName)
mp.Play
End Sub
 

agraham

Expert
Licensed User
Longtime User
B4X:
Do While mp.IsPlaying
  DoEvents
Loop
This is bad on a battery-powered device. You are burning CPU cycles and so power. You should use a Timer to control the frequency of your checking so your main thread can stop when it is not doing anything and so save power.
 

peacemaker

Expert
Licensed User
Longtime User
This loop is just for to be sure for some seconds that no need to go on.

But actually this code works strange - it plays each sound in a sequence, but a small part at the end is cut, not played. Excepting the latest one.

Extra waiting loops in this sub do not help to play fully.
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
Solved. This code is OK, but this buggy emulator play not correctly. Real device plays OK.
Topic is to be closed.
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
No - this code is not OK: some devices users report that their devices also play as the emulator: previous mp3 file is played almost to the end, then second or 2 are cut and the next mp3 in the queue is played.
But many devices play OK, one by one.

Maybe anyone who knows for now - how to play sequence of several mp3-files one by one well ?
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
I found that just MediaPlayer object plays files not completely !
For example, a MP3 file of 612 milliseconds it plays only up to 418 milliseconds in the emulator.
Why ?
 

peacemaker

Expert
Licensed User
Longtime User
Nothing helps, many tests show that need to have extra 0.5 sec at the media file end to make sure that whole file is whole audible from MediaPlayer.
 

peacemaker

Expert
Licensed User
Longtime User
Any correct solution for this moment ?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…