react-native-rtmp-publisher onConnectionFailed

q3qa4bjr  于 12个月前  发布在  React
关注(0)|答案(1)|浏览(92)
import RTMPPublisher, {
  RTMPPublisherRefProps,
  StreamState,
  BluetoothDeviceStatuses,
 } from 'react-native-rtmp-publisher';

const publisherRef = useRef<RTMPPublisherRefProps>(null);  
const url = 'rtmp://global-live.mux.com:443/app';

<RTMPPublisher
  ref={publisherRef}
  streamURL={url}
  streamName={stream_key}
  style={styles.publisher_camera}
  onDisconnect={handleOnDisconnect}
  onConnectionFailed={handleOnConnectionFailed}
  onConnectionStarted={handleOnConnectionStarted}
  onConnectionSuccess={handleOnConnectionSuccess}
  onNewBitrateReceived={handleOnNewBitrateReceived}
  onStreamStateChanged={handleOnStreamStateChanged}
  onBluetoothDeviceStatusChanged={handleBluetoothDeviceStatusChange}
 />

错误::配置流,握手错误,收到意外的21 S 0
在调用“CumbersherRef.current.startStream();”
我在streamName中尝试了不同的streamKey。我期待的是在多路复用器中创建实时流

2nc8po8w

2nc8po8w1#

您似乎正在使用react-native-rtmp-publisher库来创建带有Mux的实时流。但是,我注意到你的代码中有一个错误。
在这一行中:

const url = 'rtmp://global-live.mux.com:443/app';

您正在尝试将url变量设置为RTMP服务器URL。但是,您应该将'rtmp://global-live.mux.com:443/app'替换为实际的RTMP服务器URL。
确保将'rtmp://global-live.mux.com:443/app'替换为您要流到的RTMP服务器的URL。该URL通常包括协议(rtmp://)、服务器主机名(例如example.com)、端口号(例如1935)和应用程序名称(例如live)。请向您的RTMP服务器提供商(如Mux)验证这些详细信息。
此外,请确保将<RTMPPublisher />组件的streamName prop中的stream_key替换为Mux Dashboard中的实际流密钥。此流密钥在RTMP服务器上唯一标识您的流。
使用正确的RTMP服务器URL和流密钥更新代码后,就可以进行测试了。

相关问题