2016-06-11 6 views
1

画面共有を提供したいオン/オフ iOSの機能を使用トークボックスを使用しています。iOSでトックボックスの画面共有をオン/オフに切り替える目的C

私はデバイスの画面共有に切り替えることができますが、画面を共有した後、私はデバイスCamaraに戻ることができません。

私は次のコードを試しました。

-(void)toogleScreen{ 
    if (isSharingEnable == YES) { 
     isSharingEnable = NO; 
     NSLog(@"%@",_publisher.description); 

     _publisher.videoCapture = nil; 
     [_publisher setVideoType:OTPublisherKitVideoTypeCamera]; 
     _publisher.audioFallbackEnabled = YES; 
    } else { 
     isSharingEnable = YES; 
      [_publisher setVideoType:OTPublisherKitVideoTypeScreen]; 
     _publisher.audioFallbackEnabled = NO; 

     TBScreenCapture* videoCapture = 
     [[TBScreenCapture alloc] initWithView:self.view]; 
     [_publisher setVideoCapture:videoCapture]; 
    } 
} 
+0

彼らはへのアクセラレータパックを持っていますそれをやる。 https://github.com/opentok/screensharing-annotation-acc-pack –

答えて

1

スクリーンキャプチャをオフにするときにビデオキャプチャを設定していない可能性があります。この行:

 _publisher.videoCapture = nil; 

不必要に破壊的です。カメラとスクリーンcapturersへの内部参照を維持してみてください、とtoggleScreen機能の外にそれらを初期化します。

@implementation MyPublisher { 
    id <OTVideoCapture> _cameraCapture; 
    id <OTVideoCapture> _screenCapture; 
} 

次に、あなたのトグル方式のようなものに変更します。

-(void)toogleScreen{ 
    if (isSharingEnable == YES) { 
     isSharingEnable = NO; 
     [_publisher setVideoCapture:_cameraCapture]; 
     [_publisher setVideoType:OTPublisherKitVideoTypeCamera]; 
     _publisher.audioFallbackEnabled = YES; 
    } else { 
     isSharingEnable = YES; 
     [_publisher setVideoCapture:_screenCapture]; 
     [_publisher setVideoType:OTPublisherKitVideoTypeScreen]; 
     _publisher.audioFallbackEnabled = NO;  
    } 
} 
関連する問題