react-native-video: method onBuffer is not exist?
In usage example:
<Video source={{uri: "background"}} // Can be a URL or a local file.
ref={(ref) => {
this.player = ref
}} // Store reference
onBuffer={this.onBuffer} // Callback when remote video is buffering
onError={this.videoError} // Callback when video cannot be loaded
style={styles.backgroundVideo} />
But in Event props onBuffer prop is not exist. And in code is same too. Please delete this from docs or fix onBuffer method work.
P.S. issue#1872
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 27
If you are curois how to enable exoplayer then follow these steps:
react-native.config.jswith following content:now enable multidex following this tutorial
clean using
gradlew cleanand rebuild to make it workTry using
onPlaybackStalled={this.handleBuffer.bind(this, { isBuffering: true })} and onPlaybackResume={this.handleBuffer.bind(this, { isBuffering: false })}We explored the code and found these to be working on version ^4.4.4
Instead of creating
react-native.config.jsyou can use solution from lib readme:android/settings.gradle
// use onLoad , onLoadStart and onProgress to show buffering image
// Please use your own style, this is only an example of buffering functionality not complete screen code
const onProgress = (progress) => { if(currentTime == progress?.currentTime) { setBuffering(true) } else{ setBuffering(false) } setCurrentTime(progress?.currentTime) setSeekValue(progress?.playableDuration) }
const onLoad = ({ duration }) => { setDuration(duration) setBuffering(false) } return ( <Video source={{ uri: videoItem ? videoItem?.media_url : video?.media_url }} ref={ref => videoRef = ref} onLoad={onLoad} onLoadStart={()=>setBuffering(true)} onProgress={onProgress} /> {buffering && <Image source={your buffering gif}/> )
I found out that by default this uses MediaPlayer which doesn’t have onBuffer support but after switching to ExoPlayer it’s working!