B4J Question pause in execution

cirollo

Active Member
Licensed User
Longtime User
Hi! I've made an app with media player to reproduce some mp4 videos.

I need to stop the playback from 8:00 pm to 7:00 am of the next day, so I tried to do this:

B4X:
  If DateTime.Time(DateTime.Now).SubString2(0,2) >= start And DateTime.Time(DateTime.Now).SubString2(0,2) < stop Then
     Log(DateTime.Time(DateTime.Now).SubString2(0,2))
     Riproduci
   Else
     'facciamo partire un timer finchè non è orario
     Do While DateTime.Time(DateTime.Now).SubString2(0,2) < start Or DateTime.Time(DateTime.Now).SubString2(0,2) > stop     
       Log(DateTime.Time(DateTime.Now))
     Loop
     Riproduci
   End If

the problem is that, when the time is 9:00 pm for example (start = 7 and stop=8) the loop with
Log(DateTime.Time(DateTime.Now))

starts correctly but it takes 90% of CPU usage and, after some time, crashes the app...

tried also with timer (calling a timer of 60000 milliseconds=1 minute) until the start time but it was the same...

also using only loop without log

any ideas?

thanks, cirollo
 
Top