@@ -1208,6 +1208,16 @@ void ctr_internal_media_recalcy(int oldWindowHeight) {
1208
1208
}
1209
1209
}
1210
1210
1211
+ void ctr_internal_media_update_timers (ctr_object * media ) {
1212
+ for (int i = 1 ; i <= CtrMaxMediaTimers ; i ++ ) {
1213
+ if (CtrMediaTimers [i ] < 0 ) continue ;
1214
+ if (CtrMediaTimers [i ] == 0 ) {
1215
+ ctr_media_event_timer (media , CTR_DICT_ON_TIMER , i );
1216
+ }
1217
+ CtrMediaTimers [i ]-- ;
1218
+ }
1219
+ }
1220
+
1211
1221
/**
1212
1222
* @def
1213
1223
* [ Media ] screen: [ Text ]
@@ -1296,15 +1306,6 @@ ctr_object* ctr_media_screen(ctr_object* myself, ctr_argument* argumentList) {
1296
1306
SDL_RenderCopy (CtrMediaRenderer , texture , & s , & dimensions );
1297
1307
}
1298
1308
myself -> info .sticky = 1 ;
1299
- if (CtrMediaEventListenFlagTimer ) {
1300
- for (int i = 1 ; i <= CtrMaxMediaTimers ; i ++ ) {
1301
- if (CtrMediaTimers [i ] < 0 ) continue ;
1302
- if (CtrMediaTimers [i ] == 0 ) {
1303
- ctr_media_event_timer (myself , CTR_DICT_ON_TIMER , i );
1304
- }
1305
- CtrMediaTimers [i ]-- ;
1306
- }
1307
- }
1308
1309
if (CtrMediaEventListenFlagStep ) {
1309
1310
ctr_send_message (myself , CTR_DICT_ON_STEP , strlen (CTR_DICT_ON_STEP ), NULL );
1310
1311
}
@@ -1313,7 +1314,10 @@ ctr_object* ctr_media_screen(ctr_object* myself, ctr_argument* argumentList) {
1313
1314
ctr_internal_media_reset ();
1314
1315
return myself ;
1315
1316
}
1317
+ //Update timers, both outside and inside event loop (otherwise you could stall it)
1318
+ if (CtrMediaEventListenFlagTimer ) ctr_internal_media_update_timers (myself );
1316
1319
while (SDL_PollEvent (& event )) {
1320
+ if (CtrMediaEventListenFlagTimer ) ctr_internal_media_update_timers (myself );
1317
1321
player = NULL ;
1318
1322
focusImage = NULL ;
1319
1323
if (controllableObject ) {
0 commit comments