React-native-youtube: player don't show controls

Created on 10 Jul 2017  路  5Comments  路  Source: davidohayon669/react-native-youtube

Hello,

I have update your package to "react-native-youtube": "^1.0.0-alpha.6". I am able to play the video at times but few times controls are not shown on android device and hence unable to play video. Also when I build my app, I am not able to play video. Controls are not displayed in released app.

code is:

ref={(component) => {
this._youTubeRef = component;
}}

                apiKey="api-key"
                videoId="video-id"
                play={this.state.isPlaying}
                loop={this.state.isLooping}
                fullscreen={this.state.fullscreen}
                controls={1}
                style={styles.player}
                onError={e => console.log( e.error)}
                onReady={e => this.setState({ isReady: true })}
                onChangeState={e => this.setState({ status: e.state })}
                onChangeQuality={e => this.setState({ quality: e.quality })}
                onChangeFullscreen={e => this.setState({ fullscreen: e.isFullscreen })}
                onProgress={Platform.OS === 'ios'
        ? e => this.setState({ duration: e.duration, currentTime: e.currentTime })
        : undefined}
            />
        </ScrollView>

on each button click a new video will open on new page.

Please guide me.

Thanks!

Most helpful comment

@ishita-kothari
this hack works for me

export default class extends Component {
    state = {
        height: 215
    }

    handleReady = () => {
        setTimeout(() => this.setState({ height: 216 }), 200);
    }

    render() {
        return (
            <YouTube
                apiKey   = {config.YOUTUBE_API_KEY}
                ref      = {item => this.player = item}
                videoId  = {getVideoId(uri)}
                controls = {1}
                onReady  = {this.handleReady}
                style    = {{ alignSelf: 'stretch', height: height }}
            />
        );
    }
}

All 5 comments

131

I am still not able to run the video with controls. Can anyone give me proper solution?

@ishita-kothari there is a reason #131 is labeled with "bug"

@ishita-kothari
this hack works for me

export default class extends Component {
    state = {
        height: 215
    }

    handleReady = () => {
        setTimeout(() => this.setState({ height: 216 }), 200);
    }

    render() {
        return (
            <YouTube
                apiKey   = {config.YOUTUBE_API_KEY}
                ref      = {item => this.player = item}
                videoId  = {getVideoId(uri)}
                controls = {1}
                onReady  = {this.handleReady}
                style    = {{ alignSelf: 'stretch', height: height }}
            />
        );
    }
}

@wack17s thank you. Seems this hack worked.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

idhowardgj94 picture idhowardgj94  路  3Comments

dblazeski picture dblazeski  路  5Comments

smad picture smad  路  6Comments

MattJLeach picture MattJLeach  路  5Comments

savioseb picture savioseb  路  4Comments