react-native-video-player icon indicating copy to clipboard operation
react-native-video-player copied to clipboard

How to show activity indicator when video is buffering?

Open imbudhiraja opened this issue 7 years ago • 14 comments

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

imbudhiraja avatar Jun 12 '17 07:06 imbudhiraja

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

cornedor avatar Jun 12 '17 08:06 cornedor

+1

isAlmogK avatar Aug 01 '17 05:08 isAlmogK

Same issue

bisht2ankit avatar Dec 02 '17 11:12 bisht2ankit

+1

miladnit avatar Feb 20 '18 23:02 miladnit

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

uribro avatar Mar 07 '18 21:03 uribro

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

JP6720 avatar Apr 24 '20 08:04 JP6720

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

JP6720 avatar Apr 24 '20 09:04 JP6720

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

max-kim avatar Jun 17 '20 12:06 max-kim

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

ghost avatar Sep 03 '20 10:09 ghost

+1

mallikarjuna-sharma avatar Mar 09 '21 17:03 mallikarjuna-sharma

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

AtaMuhiuldin avatar Mar 29 '21 07:03 AtaMuhiuldin

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

fukemy avatar Jun 09 '22 09:06 fukemy

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

sumitmitra255 avatar Oct 02 '22 12:10 sumitmitra255

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

tanzeel-abdulWahid avatar Sep 06 '23 22:09 tanzeel-abdulWahid