File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ namespace pen
55
55
bool os_set_keychain_item (const Str& identifier, const Str& key, const Str& value);
56
56
Str os_get_keychain_item (const Str& identifier, const Str& key);
57
57
bool os_is_backgrounded ();
58
+ void os_register_background_callback (void (*callback)(bool ));
58
59
59
60
// music
60
61
struct music_item
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ -(MPRemoteCommandHandlerStatus)like;
83
83
pen_text_field* text_field = nullptr ;
84
84
bool show_on_screen_keyboard = false ;
85
85
pen::music_player_remote music_remote;
86
+ void (*background_callback)(bool ) = nullptr ;
86
87
};
87
88
os_context s_context;
88
89
@@ -172,6 +173,24 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N
172
173
}
173
174
}
174
175
176
+ - (void )applicationWillResignActive : (UIApplication *)app
177
+ {
178
+ // pairs with applicationDidBecomeActive
179
+ if (s_context.background_callback )
180
+ {
181
+ s_context.background_callback (true );
182
+ }
183
+ }
184
+
185
+ - (void )applicationDidBecomeActive : (UIApplication *)app
186
+ {
187
+ // pairs with applicationWillResignActive
188
+ if (s_context.background_callback )
189
+ {
190
+ s_context.background_callback (true );
191
+ }
192
+ }
193
+
175
194
-(MPRemoteCommandHandlerStatus)play {
176
195
if (s_context.music_remote .pause )
177
196
{
@@ -799,4 +818,9 @@ void music_set_now_playing_time_info(u32 position_ms, u32 duration_ms)
799
818
bool os_is_backgrounded () {
800
819
return [[UIApplication sharedApplication ] applicationState ] == UIApplicationStateBackground;
801
820
}
821
+
822
+ void os_register_background_callback (void (*callback)(bool ))
823
+ {
824
+ s_context.background_callback = callback;
825
+ }
802
826
}
You can’t perform that action at this time.
0 commit comments