简体   繁体   English

React Native - requireNativeComponent:在 UIManager 中找不到“RTCVideoView”

[英]React Native - requireNativeComponent: 'RTCVideoView' was not found in the UIManager

This is my Code:这是我的代码:

            import React, { Component } from 'react';
            // import { Platform } from 'react-native';
            import {
                RTCPeerConnection,
                RTCMediaStream,
                RTCIceCandidate,
                RTCSessionDescription,
                RTCView,
                MediaStreamTrack,
                getUserMedia,
            } from 'react-native-webrtc';

            class App extends Component {
                // Initial state
                state = {
                    videoURL: null,
                    isFront: true
                }

                componentDidMount() {
                    const configuration = { "iceServers": [{ "url": "stun:stun.l.google.com:19302" }] };
                    const pc = new RTCPeerConnection(configuration);
                    const { isFront } = this.state;
                    MediaStreamTrack.getSources(sourceInfos => {
                        console.log('MediaStreamTrack.getSources', sourceInfos);
                        let videoSourceId;
                        for (let i = 0; i < sourceInfos.length; i++) {
                            const sourceInfo = sourceInfos[i];
                            // I like ' than "
                            if (sourceInfo.kind === 'video' && sourceInfo.facing === (isFront ? 'front' : 'back')) {
                                videoSourceId = sourceInfo.id;
                            }
                        }
                        getUserMedia({
                            audio: true,
                            // THIS IS FOR SIMULATOR ONLY
                            // In fact, you better test on real iOS/Android device
                            // We just can test audio on simulator, so i set video = false
                            // video: Platform.OS === 'ios' ? false : {
                            video: {
                                mandatory: {
                                    minWidth: 500, // Provide your own width, height and frame rate here
                                    minHeight: 300,
                                    minFrameRate: 30
                                },
                                facingMode: (isFront ? 'user' : 'environment'),
                                optional: (videoSourceId ? [{ sourceId: videoSourceId }] : [])
                            }
                        }, (stream) => {
                            // use arrow function :)
                            // (stream) or stream are fine
                            console.log('Streaming OK', stream);
                            this.setState({
                                videoURL: stream.toURL()
                            });
                            pc.addStream(stream);
                        }, error => {
                            console.log('Oops, we getting error', error.message);
                            throw error;
                        });
                    });
                    pc.createOffer((desc) => {
                        pc.setLocalDescription(desc, () => {
                            // Send pc.localDescription to peer
                            console.log('pc.setLocalDescription');
                        }, (e) => { throw e; });
                    }, (e) => { throw e; });

                    pc.onicecandidate = (event) => {
                        // send event.candidate to peer
                        console.log('onicecandidate', event);
                    };

                }

                render() {
                    return (
                        <RTCView streamURL={this.state.videoURL} style={styles.container} />
                    );
                }
            }
            const styles = {
                container: {
                    flex: 1,
                    backgroundColor: '#ccc',
                    borderWidth: 1,
                    borderColor: '#000'
                }
            };

            export default App;

Why do i keep getting the error on line int he title of the question?.为什么我在问题的标题中不断收到错误?

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

This is common problem when you forgot to do npx pod-install这是您忘记执行npx pod-install时的常见问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React native 不变冲突:requireNativeComponent:在 UIManager 中找不到“RNCViewPager” - React native Invariant Violation: requireNativeComponent: "RNCViewPager" was not found in the UIManager 不变违规:requireNativeComponent:在反应原生的 UIManager 中找不到“FastImageView” - Invariant Violation: requireNativeComponent: “FastImageView” was not found in the UIManager in react native requireNativeComponent:在 UIManager 上找不到“RNSScreen” - requireNativeComponent: "RNSScreen" was not found on the UIManager React-native:requireNativeComponent:升级到最新版本后在 UIManager 中找不到“RNGestureHandlerRootView” - React-native: requireNativeComponent: "RNGestureHandlerRootView" was not found in the UIManager after upgrading to latest version react native 在 UIManager 中找不到 requireNativeComponent - requireNativeComponent was not found in UIManager requireNativeComponent:在 UIManager 中找不到“RNSVGLinearGradient” - requireNativeComponent: 'RNSVGLinearGradient' was not found in the UIManager 不变违规:requireNativeComponent:在 UIManager 中找不到“RNCSafeAreaView”。 在 react-native 和 expo 应用程序中 - Invariant Violation: requireNativeComponent: “RNCSafeAreaView” was not found in the UIManager. in react-native with expo app requireNativeComponent:在 UIManager 中找不到“RNSScreenStackHeaderConfig” - requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager React-Native-SVG 错误:不变违规:requireNativeComponent:在 UIManager 中找不到“RNSVGGroup” - React-Native-SVG Error: Invariant Violation: requireNativeComponent: "RNSVGGroup" was not found in the UIManager “不变违规:requireNativeComponent:在 UIManager 中找不到“RNSScreen”。” 反应本机 cli 中的错误 - 'Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager.' error in react native cli
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM