瀏覽代碼

iOS: fix native video

Fixed view not being displayed.
Fixed view orientation change.
Sergey Minakov 4 年之前
父節點
當前提交
6b2483c331
共有 2 個文件被更改,包括 10 次插入1 次删除
  1. 6 0
      platform/iphone/native_video_view.m
  2. 4 1
      platform/iphone/view_controller.mm

+ 6 - 0
platform/iphone/native_video_view.m

@@ -71,6 +71,12 @@
 	[self observeVideoAudio];
 }
 
+- (void)layoutSubviews {
+	[super layoutSubviews];
+
+	self.avPlayerLayer.frame = self.bounds;
+}
+
 - (void)observeVideoAudio {
 	printf("******** adding observer for sound routing changes\n");
 	[[NSNotificationCenter defaultCenter]

+ 4 - 1
platform/iphone/view_controller.mm

@@ -208,8 +208,11 @@
 	} else {
 		// Create autoresizing view for video playback.
 		GodotNativeVideoView *videoView = [[GodotNativeVideoView alloc] initWithFrame:self.view.bounds];
-		videoView.autoresizingMask = UIViewAutoresizingFlexibleWidth & UIViewAutoresizingFlexibleHeight;
+		videoView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
 		[self.view addSubview:videoView];
+
+		self.videoView = videoView;
+
 		return [self.videoView playVideoAtPath:filePath volume:videoVolume audio:audioTrack subtitle:subtitleTrack];
 	}
 }