diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/os_android.cpp | 7 | ||||
-rw-r--r-- | platform/android/os_android.h | 2 | ||||
-rw-r--r-- | platform/iphone/app_delegate.mm | 1 | ||||
-rwxr-xr-x | platform/iphone/gl_view.mm | 38 | ||||
-rw-r--r-- | platform/iphone/os_iphone.cpp | 6 | ||||
-rw-r--r-- | platform/iphone/os_iphone.h | 2 |
6 files changed, 49 insertions, 7 deletions
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 3a101515da..5bc433e85f 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -676,7 +676,7 @@ String OS_Android::get_unique_ID() const { return OS::get_unique_ID(); } -Error OS_Android::native_video_play(String p_path) { +Error OS_Android::native_video_play(String p_path, float p_volume) { if (video_play_func) video_play_func(p_path); return OK; @@ -719,6 +719,11 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFu get_locale_func=p_get_locale_func; get_model_func=p_get_model_func; get_unique_id_func=p_get_unique_id; + + video_play_func = p_video_play_func; + video_is_playing_func = p_video_is_playing_func; + video_pause_func = p_video_pause_func; + video_stop_func = p_video_stop_func; show_virtual_keyboard_func = p_show_vk; hide_virtual_keyboard_func = p_hide_vk; diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 76139c8a2d..e6d0f7eded 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -208,7 +208,7 @@ public: void process_event(InputEvent p_event); void init_video_mode(int p_video_width,int p_video_height); - virtual Error native_video_play(String p_path); + virtual Error native_video_play(String p_path, float p_volume); virtual bool native_video_is_playing(); virtual void native_video_pause(); virtual void native_video_stop(); diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 56cb73ba7b..c5ac5d9263 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -165,6 +165,7 @@ static int frame_count = 0; - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { printf("****************** did receive memory warning!\n"); + OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_MEMORY_WARNING); }; - (void)applicationDidFinishLaunching:(UIApplication*)application { diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index 402c755094..c482c36a30 100755 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -32,6 +32,7 @@ #include "os_iphone.h" #include "core/os/keyboard.h" #include "core/globals.h" +#include "servers/audio_server.h" #import "gl_view.h" @@ -48,6 +49,9 @@ int gl_view_base_fb; static String keyboard_text; static GLView* _instance = NULL; +static bool video_found_error = false; +static float video_previous_volume = 0.0f; + void _show_keyboard(String p_existing) { keyboard_text = p_existing; printf("instance on show is %p\n", _instance); @@ -60,8 +64,13 @@ void _hide_keyboard() { keyboard_text = ""; }; -bool _play_video(String p_path) { +bool _play_video(String p_path, float p_volume) { + float player_volume = p_volume * AudioServer::get_singleton()->get_singleton()->get_stream_global_volume_scale(); + video_previous_volume = [[MPMusicPlayerController applicationMusicPlayer] volume]; + + [[MPMusicPlayerController applicationMusicPlayer] setVolume: player_volume]; + p_path = Globals::get_singleton()->globalize_path(p_path); NSString* file_path = [[[NSString alloc] initWithUTF8String:p_path.utf8().get_data()] autorelease]; @@ -87,6 +96,8 @@ bool _play_video(String p_path) { bool _is_video_playing() { //NSInteger playback_state = _instance.moviePlayerController.playbackState; + if (video_found_error) + return false; return (_instance.moviePlayerController.playbackState == MPMoviePlaybackStatePlaying); } @@ -97,6 +108,7 @@ void _pause_video() { void _stop_video() { [_instance.moviePlayerController stop]; [_instance.moviePlayerController.view removeFromSuperview]; + [[MPMusicPlayerController applicationMusicPlayer] setVolume: video_previous_volume]; } @implementation GLView @@ -506,13 +518,37 @@ static void clear_touches() { } - (void)moviePlayBackDidFinish:(NSNotification*)notification { + + + NSNumber* reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey]; + switch ([reason intValue]) { + case MPMovieFinishReasonPlaybackEnded: + //NSLog(@"Playback Ended"); + break; + case MPMovieFinishReasonPlaybackError: + //NSLog(@"Playback Error"); + video_found_error = true; + break; + case MPMovieFinishReasonUserExited: + //NSLog(@"User Exited"); + video_found_error = true; + break; + default: + //NSLog(@"Unsupported reason!"); + break; + } + MPMoviePlayerController *player = [notification object]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player]; + [_instance.moviePlayerController stop]; [_instance.moviePlayerController.view removeFromSuperview]; + + [[MPMusicPlayerController applicationMusicPlayer] setVolume: video_previous_volume]; } @end diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index 756e8b575e..2ef732183b 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -485,13 +485,13 @@ String OSIPhone::get_locale() const { return locale_code; } -extern bool _play_video(String p_path); +extern bool _play_video(String p_path, float p_volume); extern bool _is_video_playing(); extern void _pause_video(); extern void _stop_video(); -Error OSIPhone::native_video_play(String p_path) { - if ( _play_video(p_path) ) +Error OSIPhone::native_video_play(String p_path, float p_volume) { + if ( _play_video(p_path, p_volume) ) return OK; return FAILED; } diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index 643bf2b5e3..14b46816e9 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -184,7 +184,7 @@ public: void set_unique_ID(String p_ID); String get_unique_ID() const; - virtual Error native_video_play(String p_path); + virtual Error native_video_play(String p_path, float p_volume); virtual bool native_video_is_playing() const; virtual void native_video_pause(); virtual void native_video_stop(); |