diff --git a/ios/ScratchJr/src/IO.m b/ios/ScratchJr/src/IO.m index 1d11d86..f2eea80 100644 --- a/ios/ScratchJr/src/IO.m +++ b/ios/ScratchJr/src/IO.m @@ -280,12 +280,14 @@ NSMutableDictionary *soundtimers; } + (void)soundEnded:(NSTimer*)timer { - NSString *soundName = [[timer userInfo] objectForKey:@"soundName"]; - if (sounds[soundName] == nil) return; - NSString *callback = [NSString stringWithFormat:@"iOS.soundDone('%@');", soundName]; - UIWebView *webview = [ViewController webview]; + NSString *soundName = [[timer userInfo] objectForKey:@"soundName"]; + if (sounds[soundName] == nil) return; + NSString *callback = [NSString stringWithFormat:@"iOS.soundDone('%@');", soundName]; + UIWebView *webview = [ViewController webview]; + dispatch_async(dispatch_get_main_queue(), ^{ [webview stringByEvaluatingJavaScriptFromString:callback]; - } + }); +} + (NSString *)stopSound :(NSString*)name { AVAudioPlayer *snd = sounds[name]; diff --git a/ios/ScratchJr/src/ScratchJr.m b/ios/ScratchJr/src/ScratchJr.m index 7d531f8..e5b6cca 100644 --- a/ios/ScratchJr/src/ScratchJr.m +++ b/ios/ScratchJr/src/ScratchJr.m @@ -19,7 +19,9 @@ NSString *oncomplete; + (NSString *) hideSplash :(NSString *)body{ UIImageView* splashScreen = [ViewController splashScreen]; - [splashScreen removeFromSuperview]; + dispatch_async(dispatch_get_main_queue(), ^{ + [splashScreen removeFromSuperview]; + }); return @"1"; }