1

React ネイティブ iOS を使用して webRTC 経由でビデオ チャットを作成します。そのために、私は iOS 用の反応ネイティブ コードを作成しました。カメラへのアクセスを求めていますが、その後、ビデオの読み込みに失敗し、警告メッセージが表示されます。

Failed to bind EAGLDrawable: <CAEAGLLayer: 0x16d50e30> to GL_RENDERBUFFER 1
Failed to make complete framebuffer object 8cd6

上記の警告は、ビデオ フレームをレンダリングするためにカメラにビューが表示されないことが原因であることを知っています。しかし、フレームの提供に失敗した反応コードの何が問題なのかわかりません。私のコードは次のとおりです。

import React, {
  AppRegistry,
  Component,
  StyleSheet,
  Text,
  View
} from 'react-native';

var WebRTC = require('react-native-webrtc');
var {
  RTCPeerConnection,
  RTCMediaStream,
  RTCIceCandidate,
  RTCSessionDescription,
  RTCView
} = WebRTC;


var container;
var configuration = {"iceServers": [{"url": "stun:stun.l.google.com:19302"}]};
  var pc = new RTCPeerConnection(configuration);
  navigator.getUserMedia({ "audio": true, "video": true }, function (stream) {
    pc.addStream(stream);
  });
  pc.createOffer(function(desc) {
    pc.setLocalDescription(desc, function () {
    // Send pc.localDescription to peer
  }, function(e) {});
  }, function(e) {});
  pc.onicecandidate = function (event) {
  // send event.candidate to peer
};

var RCTWebRTCDemo = React.createClass({
  getInitialState: function() {
    return {videoURL: null};
  },
  componentDidMount: function() {
    container = this;
  },
  render: function() {
    return (
      <View style={styles.container}>
        <RTCView streamURL={this.state.videoURL}/>
      </View>
    );
  }
});

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('RCTWebRTCDemo', () => RCTWebRTCDemo);

どこが間違っているのか知りたいですか?

4

1 に答える 1

2

前にフレームを設定しました

<View style={styles.container}>
        <RTCView streamURL={this.state.videoURL}/>
 </View>

しかし、それは間違っていました。RTCView の作成は少し異なるため、RTCView 構文内でフレームを設定します。正しい方法は、

       <View>
        <RTCView streamURL={this.state.videoURL} style={styles.container}/>
      </View>
于 2016-04-06T05:11:24.200 に答える