注: iOS用のストリーム取り込みSDKは、プレーヤービューではなく、収集したビデオフレームを回転させます。 iOS用のストリーム取り込みSDKを使用してランドスケープモードでストリームを取り込むには、コントローラコードでポートレート表示をロックする必要があります。
ランドスケープモードでストリームを取り込む必要がある場合は、UIのランドスケープモードに合った適応計画を作成します。 この適応プランでは、プレビュービューを回転させる必要はない。 たとえば、プレビュービューがフルスクリーンの場合、「いいね」ボタンなどのボタンのフレームを調整できることを除いて、プレビュービューを横向きモードで変更する必要はありません。
手順
デバイスのディスプレイの向きを検出します。
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleDeviceOrientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil];handleDeviceOrientationDidChangeコールバックで、ストリーム取り込みのランドスケープまたはポートレートモードを設定します。
- (void)handleDeviceOrientationDidChange: (UIInterfaceOrientation)interfaceOrientation { UIDevice *device = [UIDevice currentDevice] ; switch (device.orientation) { case UIDeviceOrientationFaceUp: NSLog(@"Screen up"); break; case UIDeviceOrientationFaceDown: NSLog(@"Screen down"); break; case UIDeviceOrientationUnknown: NSLog(@"Unknown"); break; case UIDeviceOrientationLandscapeLeft: { NSLog(@"Left side down"); // Ingest a stream in the landscape mode. [self destroySession]; // Interrupt the current stream ingest. // We recommend that you add a loading method here. If you interrupt and then resume the current stream ingest, the system disables and then enables the camera to collect a stream. _isScreenHorizontal = YES; // Specify whether to use the portrait mode or landscape mode. To use the landscape mode, set this parameter to YES. [self testPushCapture]; // Re-ingest a stream. } break; case UIDeviceOrientationLandscapeRight: NSLog(@"Right side down"); break; case UIDeviceOrientationPortrait: { NSLog(@"Portrait"); // Ingest a stream in the portrait mode. [self destroySession]; // Interrupt the current stream ingest. _isScreenHorizontal = NO; // Specify whether to use the portrait mode or landscape mode. To use the landscape mode, set this parameter to NO. [self testPushCapture]; // Re-ingest a stream. } break; case UIDeviceOrientationPortraitUpsideDown: NSLog(@"Portrait with upside down"); break; default: NSLog(@"Unknown"); break; } }デバイスからログオフします。
- (void)dealloc{ [[NSNotificationCenter defaultCenter] removeObserver:self]; [[UIDevice currentDevice]endGeneratingDeviceOrientationNotifications]; }