perrystreetsoftware / react-native-rtmpview

Show RTMP views on iOS + Android using React Native
MIT License
98 stars 16 forks source link

It is blank screen in Android... #19

Open lpylinan opened 5 years ago

lpylinan commented 5 years ago

Logs: I/ReactRTMPView: Lifecycle: onHostPause W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.perrystreetsoftware.RNRtmpViewManager I/ReactRTMPView: Lifecycle: onHostResume I/ReactRTMPView: Unable to play; not idle

somoso commented 4 years ago

For what it's worth, I had this issue, but I didn't follow the example closely enough:

import { RtmpView } from 'react-native-rtmpview';

export default class Example extends Component {
  componentDidMount() {
    // *** This is the key bit!
    this.player.initialize();
    // *** End of key bit!
  }

  render() {
    return (
        <RtmpView
          style={styles.player}
          shouldMute={true}
          ref={e => { this.player = e; }}
          onPlaybackState={(data) => {
            this.handlePlaybackState(data);
          }}
          onFirstVideoFrameRendered={(data) => {
            this.handleFirstVideoFrameRendered(data);
          }}
          url="rtmp://localhost:1935/live/stream"
        />
    )
  }
}

Note the componentDidMount() has a this.player.initialize() which is absolutely crucial for initialising all the components properly (and one cannot initialise properly without the ref bit)