File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -274,8 +274,18 @@ void NativeMidi_DestroySong(NativeMidi_Song *song)
274274 }
275275}
276276
277+ static NativeMidi_Song * paused_song = NULL ;
278+ static MusicTimeStamp paused_time = 0 ;
279+ static bool resume = false;
280+
277281void NativeMidi_Start (NativeMidi_Song * song , int loops )
278282{
283+ if (!resume ) {
284+ // If we are not resuming a paused song, clear any existing paused info.
285+ paused_song = NULL ;
286+ paused_time = 0 ;
287+ }
288+
279289 if (song ) {
280290 if (currentsong ) {
281291 MusicPlayerStop (currentsong -> player );
@@ -294,17 +304,29 @@ void NativeMidi_Start(NativeMidi_Song *song, int loops)
294304 latched_volume += 1.0f ; // +1 just make this not match.
295305 NativeMidi_SetVolume (vol );
296306
297- MusicPlayerSetTime (song -> player , 0 );
307+ MusicPlayerSetTime (song -> player , resume ? paused_time : 0 );
298308 MusicPlayerStart (song -> player );
299309 }
300310}
301311
302312void NativeMidi_Pause (void )
303313{
314+ if (currentsong ) {
315+ paused_song = currentsong ;
316+ MusicPlayerGetTime (currentsong -> player , & paused_time );
317+ NativeMidi_Stop ();
318+ }
304319}
305320
306321void NativeMidi_Resume (void )
307322{
323+ if (paused_song ) {
324+ resume = true;
325+ NativeMidi_Start (paused_song , paused_song -> loops );
326+ paused_song = NULL ;
327+ paused_time = 0 ;
328+ resume = false;
329+ }
308330}
309331
310332void NativeMidi_Stop (void )
You can’t perform that action at this time.
0 commit comments