TheWidlarzGroup / react-native-video-player

A video player for React Native with controls
MIT License
515 stars 316 forks source link

How to show activity indicator when video is buffering? #31

Open imbudhiraja opened 7 years ago

imbudhiraja commented 7 years ago

I have to show an activity indicator when video is buffering.

cornedor commented 7 years ago

That is currently not possible, I'll try to add it soon.

isAlmogK commented 7 years ago

+1

bisht2ankit commented 6 years ago

Same issue

miladnit commented 6 years ago

+1

uribro commented 6 years ago

I achieve it with this code, hope it helps:

import {ActivityIndicator} from 'react-native';

constructor(props) {
    super(props);
    this.state = {opacity: 0};
}

 onLoadStart = () => {
    this.setState({opacity: 1});
}

onLoad = () => {
    this.setState({opacity: 0});
}

onBuffer = ({isBuffering}) => {
    this.setState({opacity: isBuffering ? 1 : 0});
}

render() {
    return (
        <View style={styles.container}>
            <Video
                onBuffer={this.onBuffer}
                onLoadStart={this.onLoadStart}
                onLoad={this.onLoad}
            />
              <ActivityIndicator
                animating
                size="large"
                color={Colors.Pink}
                style={[styles.activityIndicator, {opacity: this.state.opacity}]}
            />
        </View>
    );
}
styles.activityIndicator: {
        position: 'absolute',
        top: 70,
        left: 70,
        right: 70,
        height: 50,
    },

opacity is used instead of isLoading state due to react native bug see: https://stackoverflow.com/questions/38579665/reactnative-activityindicator-not-showing-when-animating-property-initiate-false

JP6720 commented 4 years ago

How to show when video is in List. I want to show buffering on every video.

JP6720 commented 4 years ago

How to use this all methods for all videos when videos in Flatlist. Because mostly state can use for single component only.

max-kim commented 4 years ago

How to use this all methods for all videos when videos in Flatlist. Because mostly state can use for single component only.

You can isolate all of items to dedicated component with its own state

ghost commented 4 years ago

It's been more than 2 years. Any update on this?

mallikarjuna-sharma commented 3 years ago

+1

AtaMuhiuldin commented 3 years ago

@uribro thanks, you solution worked for me as well!

fukemy commented 2 years ago

@uribro I can click to play video after set position 'absolute' of indicator

sumitmitra255 commented 1 year ago

Hello thank you all for this post and the replies. I have achecived a really good buffering indicator.

tanzeel-abdulWahid commented 1 year ago

There is a default loader when video is played. How can we hide that?