iOS Question DoEvents

db0070

Active Member
Licensed User
Longtime User
I have a play button and a series of memory buttons. When play is clicked, MP1 starts playing and I want to store MP1.Position at the moment a user clicks one of the memory buttons and continue playing. The following routine (a small part extracted), works well in B4a because of DoEvents. But I can't make it work very well in B4i. Can anyone suggest an equivalent for DoEvents? I was thinking of another timer at 1ms but how would I implement that to check if one of the memory buttons has been pressed? (I set the memory buttons to use the same click event, which also triggers timer2)

B4X:
'timer2 set at 100mS intervals
Sub timer2_Tick
Dim n As Int
.
.
.
 
If MP1.IsPlaying And col(n) <>  Colors.Blue Then
   If col(n) = Colors.Yellow  Then
     MP1.Pause
     colbtn(n).Color = Colors.Green
      'DoEvents from b4a was here
   End If
End If
'DoEvents from b4a was here
.
. 'process other buttons
.
End Sub
 

db0070

Active Member
Licensed User
Longtime User
The reason I am using the timer is to update a progress bar for each button when it is playing MP1 that is stored for that button. That bit of code is not shown
 
Upvote 0

db0070

Active Member
Licensed User
Longtime User
I need the doEvents because when another memory button (which has another piece of audio stored) is clicked it does not appear to click until after the audio of the first button is completed. The same code in B4a works smoothly
 
Upvote 0

db0070

Active Member
Licensed User
Longtime User
I am trying to play a part of the audio and looping that part. For example if a button has stored position 25 to 90 of an audio then loop from mp1.position 25 to mp1.position 90 and at the same time monitor for any other button click events. Hence the use of a timer to see if position has reached 90. DoEvents works very well in b4a but I can't find an equivalent in b4i
 
Upvote 0

db0070

Active Member
Licensed User
Longtime User
Ok, I think I fixed it. I had the timer firing at 50mS. I increased it to 250mS and is now working good enough - though not as good as b4a.

Is there a way to fire a mediaplayer event when it reaches a certain position, other then using timers?
 
Upvote 0
Top