【问题标题】:Failed to bind EAGLDrawable in WebRTC react native无法在 WebRTC 中绑定 EAGLDrawable 反应本机
【发布时间】:2016-04-05 07:33:05
【问题描述】:

我将使用 React 本机 iOS 通过 webRTC 创建视频聊天。为此,我为 iOS 编写了 react 本机代码。它要求我访问相机,但之后它无法加载视频并抛出一个温暖的消息,

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);

我很想知道我错在哪里?

【问题讨论】:

  • 也许你把create pc和getUserMedia改成ComponentDidMount()?
  • 正如有人在 repo 上所说,您是否使用 RTCView 设置了高度和宽度?
  • @zxcpoiu 谢谢..我解决了这个问题。右框架被错误地设置为 RTCView。

标签: reactjs react-native webrtc openwebrtc


【解决方案1】:

我在之前设置了框架

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

但它是错误的。 RTCView 创建略有不同,因此我们在 RTCView 语法中设置框架。正确的做法是,

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-20
    • 1970-01-01
    • 1970-01-01
    • 2020-03-14
    • 2015-05-15
    • 1970-01-01
    相关资源
    最近更新 更多