ytdl-js / react-native-ytdl

A YouTube downloader for React Native
121 stars 46 forks source link

I got the link using react-native-ytdl but it doesn't play #86

Closed munhyok closed 3 years ago

munhyok commented 3 years ago
componentDidMount(){

            const {route, navigation} = this.props; 
            const {gameVid} = route.params;

                const rendertest = async (gameVid) => {

                    const format = await ytdl(gameVid, { quality: '22'});
                    let test = JSON.stringify(format[0].url);

                    return test

                }

                    rendertest(gameVid).then(finalValue => {
                        console.log(typeof(finalValue)+": "+finalValue)
                        //this.state.testvalue = finalValue;
                        this.setState({
                            testvalue: finalValue,

                        });

                    })

        }
{this.state.testvalue ? (
    <Video
        source={{uri: this.state.testvalue}}
        resizeMode="cover"
        isNetwork={this.state.done}
        style={{width: '100%', height: 250, position:'absolute'}}
    />
) : null}

If you insert it directly through the link obtained through ytdl, it works, but the value provided through componentDidMount is properly received, but the video does not play.

How do I make it work..?