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

Autoplay false doesn't work on async video data #24

Closed
cjmling opened this issue Jun 11, 2018 · 1 comment
Closed

Autoplay false doesn't work on async video data #24

cjmling opened this issue Jun 11, 2018 · 1 comment
Labels

Comments

@cjmling
Copy link

cjmling commented Jun 11, 2018

I am trying to async query video on componentDidMount and then display the player based on the loaded video.

Problem: Everything work , video can be play. But the player always autoplay the video.

Sample codes

class VideoPage extends Component {
    	constructor(props) {
        	super(props);
       		this.state = {
            		video: {},
        	};
    	}
    	componentDidMount() {
        	this.getVideo(this.state.videoId);
    	}
   	getVideo(){
		// query db then
		this.setState(video);	
	}

	return(){
		const {video} = this.state;
		return(
			<YouTube video={video.videoId} width={640} height={390} />
		)
	}
}
@goto-bus-stop
Copy link
Member

goto-bus-stop commented Jun 11, 2018

looks like we should use cueVideoById instead of loadVideoById here, if autoplay is false:

react-youtube/src/index.js

Lines 150 to 154 in 2c357c5

player.loadVideoById({
videoId: value,
startSeconds: this.props.startSeconds || 0,
endSeconds: this.props.endSeconds,
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants