summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/iphone/app_delegate.mm3
-rw-r--r--platform/iphone/detect.py1
-rwxr-xr-xplatform/iphone/gl_view.mm38
-rw-r--r--platform/iphone/os_iphone.cpp7
-rw-r--r--platform/iphone/os_iphone.h1
5 files changed, 48 insertions, 2 deletions
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index 76c2d06080..e214b75bb0 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -286,6 +286,9 @@ static int frame_count = 0;
if (OS::get_singleton()->get_main_loop())
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
[view_controller.view startAnimation]; // FIXME: resume seems to be recommended elsewhere
+ if (OSIPhone::get_singleton()->native_video_is_playing()) {
+ OSIPhone::get_singleton()->native_video_unpause();
+ };
}
- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration {
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index acab6fe546..a5ce376b8f 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -81,6 +81,7 @@ def configure(env):
#'-framework', 'AdSupport',
'-framework', 'MediaPlayer',
'-framework', 'AVFoundation',
+ '-framework', 'CoreMedia',
])
if env['game_center'] == 'yes':
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index a25e740883..55b5eabacf 100755
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -52,6 +52,7 @@ static GLView* _instance = NULL;
static bool video_found_error = false;
static bool video_playing = false;
static float video_previous_volume = 0.0f;
+static CMTime video_current_time;
void _show_keyboard(String p_existing) {
keyboard_text = p_existing;
@@ -107,6 +108,8 @@ bool _play_video(String p_path, float p_volume, String p_audio_track, String p_s
_instance.avAsset = [AVAsset assetWithURL:[NSURL fileURLWithPath:file_path]];
_instance.avPlayerItem =[[AVPlayerItem alloc]initWithAsset:_instance.avAsset];
+ [_instance.avPlayerItem addObserver:_instance forKeyPath:@"status" options:0 context:nil];
+
_instance.avPlayer = [[AVPlayer alloc]initWithPlayerItem:_instance.avPlayerItem];
_instance.avPlayerLayer =[AVPlayerLayer playerLayerWithPlayer:_instance.avPlayer];
@@ -166,10 +169,18 @@ bool _is_video_playing() {
void _pause_video() {
//[_instance.moviePlayerController pause];
+ video_current_time = _instance.avPlayer.currentTime;
[_instance.avPlayer pause];
video_playing = false;
}
+void _unpause_video() {
+ [_instance.avPlayer play];
+ video_playing = true;
+
+ //video_current_time = kCMTimeZero;
+};
+
void _stop_video() {
//[_instance.moviePlayerController stop];
//[_instance.moviePlayerController.view removeFromSuperview];
@@ -390,6 +401,11 @@ static void clear_touches() {
active = TRUE;
printf("start animation!\n");
animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
+
+ if (video_playing)
+ {
+ _unpause_video();
+ }
}
- (void)stopAnimation
@@ -401,6 +417,11 @@ static void clear_touches() {
[animationTimer invalidate];
animationTimer = nil;
clear_touches();
+
+ if (video_playing)
+ {
+ // save position
+ }
}
- (void)setAnimationInterval:(NSTimeInterval)interval
@@ -439,9 +460,11 @@ static void clear_touches() {
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
+#ifdef DEBUG_ENABLED
GLenum err = glGetError();
if(err)
NSLog(@"%x error", err);
+#endif
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
@@ -589,11 +612,22 @@ static void clear_touches() {
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context {
- if (object == _instance.avPlayer && [keyPath isEqualToString:@"status"]) {
- if (_instance.avPlayer.status == AVPlayerStatusFailed) {
+
+ if (object == _instance.avPlayerItem && [keyPath isEqualToString:@"status"]) {
+ if (_instance.avPlayerItem.status == AVPlayerStatusFailed || _instance.avPlayer.status == AVPlayerStatusFailed) {
_stop_video();
video_found_error = true;
}
+
+ if(_instance.avPlayer.status == AVPlayerStatusReadyToPlay &&
+ _instance.avPlayerItem.status == AVPlayerItemStatusReadyToPlay &&
+ CMTIME_COMPARE_INLINE(video_current_time, ==, kCMTimeZero)) {
+
+ //NSLog(@"time: %@", video_current_time);
+
+ [_instance.avPlayer seekToTime:video_current_time];
+ video_current_time = kCMTimeZero;
+ }
}
}
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index dee018473a..c8a132c39b 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -234,6 +234,7 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_
ev.mouse_button.x = ev.mouse_button.global_x = p_x;
ev.mouse_button.y = ev.mouse_button.global_y = p_y;
+ input->set_mouse_pos(Point2(ev.mouse_motion.x,ev.mouse_motion.y));
ev.mouse_button.button_index = BUTTON_LEFT;
ev.mouse_button.doubleclick = p_doubleclick;
ev.mouse_button.pressed = p_pressed;
@@ -488,6 +489,7 @@ String OSIPhone::get_locale() const {
extern bool _play_video(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
extern bool _is_video_playing();
extern void _pause_video();
+extern void _unpause_video();
extern void _stop_video();
Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
@@ -505,6 +507,11 @@ void OSIPhone::native_video_pause() {
_pause_video();
}
+void OSIPhone::native_video_unpause() {
+ _unpause_video();
+};
+
+
void OSIPhone::native_video_stop() {
if (native_video_is_playing())
_stop_video();
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index 7fb306ea13..bf8c5bb1c9 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -187,6 +187,7 @@ public:
virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
virtual bool native_video_is_playing() const;
virtual void native_video_pause();
+ virtual void native_video_unpause();
virtual void native_video_stop();
OSIPhone(int width, int height);