Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

2.3.メディアの取得

hkato edited this page Mar 25, 2016 · 4 revisions

自分のカメラの映像を取得して表示

  • Navigator.getUserMediaで、カメラの映像が取得できる
  • Canvasにセットする

Java

// メディアを取得
Navigator.initialize(_peer);
MediaConstraints constraints = new MediaConstraints();
_msLocal = Navigator.getUserMedia(constraints);

// 映像を表示する為のUI
Canvas canvas = (Canvas) findViewById(R.id.svSecondary);
canvas.addSrc(_msLocal, 0);

Objective-C

//メディアを取得
[SKWNavigator initialize:_peer];
SKWMediaConstraints* constraints = [[SKWMediaConstraints alloc] init];
_msLocal = [SKWNavigator getUserMedia:constraints];

// 映像を表示する為のUI
SKWVideo* localVideoView = [self.view viewWithTag:TAG_LOCAL_VIDEO];
[localVideoView addSrc:_msLocal track:0];

Swift

//メディアを取得
SKWNavigator.initialize(_peer);
let constraints:SKWMediaConstraints = SKWMediaConstraints.init();
_msLocal = SKWNavigator.getUserMedia(constraints) as SKWMediaStream
    
// 映像を表示する為のUI
let localVideoView:SKWVideo = self.view.viewWithTag(ViewTag.TAG_LOCAL_VIDEO.hashValue) as! SKWVideo
localVideoView.addSrc(_msLocal, track: 0)