I updated my nexus7 to Android 5.0 last night, and checked my app still worked.
It does, but not 100%. the app usually plays a series of clicks when something spins, and that's not working any more.
My code for playing the tick looks like this below - what I want to know is, would my Do While loop (that waits for the tick to finish playing) have any effect? I thought maybe since it blocks execution it may be optimised out by the compiler or something.
B4X:
Sub PlayTick
MP.Initialize ()
MP.Load(File.DirAssets, "tick.wav")
MP.Play
Do While MP.IsPlaying
Loop
End Sub
Thanks Erel,
Just for my education - is this the best strategy to adopt:
Initialise MP once only, in Service_Create
Load a sound file, play it.
If I need to play that sound again, just play it again (after I know the first play has ended) without re-loading it.
If I need to play a different sound, I just load the different sound and play it, no need for re-init?
1. You can also use SoundPool for short sounds. It is more efficient.
2. You can create several MediaPlayer objects if you play the same files several times.