Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
imbudhiraja opened this issue Jun 12, 2017 · 15 comments
Open

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

imbudhiraja opened this issue Jun 12, 2017 · 15 comments
Labels
enhancement stale Closed due to inactivity or lack or resources

Comments

@imbudhiraja
Copy link

imbudhiraja commented Jun 12, 2017

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

@cornedor
Copy link
Collaborator

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

@isAlmogK
Copy link

isAlmogK commented Aug 1, 2017

+1

@bisht2ankit
Copy link

Same issue

@miladnit
Copy link

+1

@uribro
Copy link
Contributor

uribro commented Mar 7, 2018

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
Copy link

JP6720 commented Apr 24, 2020

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

@JP6720
Copy link

JP6720 commented Apr 24, 2020

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

@max-kim
Copy link

max-kim commented Jun 17, 2020

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
Copy link

ghost commented Sep 3, 2020

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

@mallikarjuna-sharma
Copy link

+1

@AtaMuhiuldin
Copy link

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

@fukemy
Copy link

fukemy commented Jun 9, 2022

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

@sumitmitra255
Copy link

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

@tanzeel-abdulWahid
Copy link

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

Copy link
Contributor

This issue is stale because it has been open for 30 days with no activity. If there won't be any activity in the next 14 days, this issue will be closed automatically.

@github-actions github-actions bot added the stale Closed due to inactivity or lack or resources label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement stale Closed due to inactivity or lack or resources
Projects
None yet
Development

No branches or pull requests