-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Meteor + React #38
Comments
Hey @nathanandersen, This sounds similar to #35. Check out the |
I sent you an email about this -- I think we're getting somewhere. I see the "var ReactPlayer = function()...." but I'm not sure how to implement/render that as a React component. |
It really depends how you are managing Meteor and React and external dependencies. It looks like the proper way of using In the |
Right, I saw that and it looks like the way to go. When I try that, I get this error:
Note: I'm using the minified JS from the Is there a different way to more properly insert the React Class? In the example you referenced, it was directly defined as |
Ah ok so if you're importing using the old school ReactPlayer = ReactPlayer.default
return (
<ReactPlayer url={...} />
) But you shouldn't need to do this really. I'll play around with the build script and see if I can improve it. |
That last comment was very helpful and fixed that, thank you so much, now it is embedding. I am now struggling with the callback events -- they all seem to fire several times before the video starts playing, then do not fire correctly (say onEnded when the video ends or onPause when the video is paused). |
I suspect it has something to do with the ChromeCast error messages in the console inhibiting event calling, but then I would suspect that this is something you've seen before... |
Yeah the Chromecast errors are just a dumb side effect of the YouTube player running in a browser without the Chromecast extension installed, and shouldn't affect the callbacks. I'll have to try loading ReactPlayer in Meteor to try and reproduce this. Do you have some example code you can show me of how you are loading/rendering the player? |
Here is the code for my component with the player. It loads, renders properly, and starts playing, but it calls all the events (I loaded it with each event having a function that outputs that event name to the console) before play starts, then none of them at any point afterwards. |
Rendered with ... |
Ok so you're almost there. Notice how you are passing ReactPlayer = ReactPlayer.default
SongPlayer = React.createClass({
onPlay() {
console.log('play');
},
render() {
var youtubeConfig = { preload: true };
return (
<ReactPlayer
url='https://www.youtube.com/watch?v=yMaURUZsNdU'
onPlay={this.onPlay}
youtubeConfig={youtubeConfig}
playing={true}
/>
)
}
}); |
Thanks so much for all of this, it's really awesome. Is there a way to load another video after one ends? |
Sure, just keep your currently playing URL in state and ReactPlayer = ReactPlayer.default
SongPlayer = React.createClass({
getInitialState() {
return {
url: 'https://www.youtube.com/watch?v=yMaURUZsNdU'
}
},
onPlay() {
console.log('play');
},
onEnded() {
this.setState({ url: 'another url' })
},
render() {
var youtubeConfig = { preload: true };
return (
<ReactPlayer
url={this.state.url}
onPlay={this.onPlay}
onEnded={this.onEnded}
youtubeConfig={youtubeConfig}
playing={true}
/>
)
}
}); If you are using Meteor there is probably a better way to manage app state, but this just shows basic usage of |
@nathanandersen Note that as of version |
Hello, I also tried to use the dist/ReactPlayer.js after cloning and installing the repo (master) but it says ReactPlayer is undefined. |
Ok so what I missed with bower is that I'd have to commit the compiled Meanwhile, the |
@ioRekz This is now fixed in
|
great thanks ! On Tue, Mar 8, 2016 at 11:05 AM, Pete Cook notifications@github.com wrote:
|
Run `npm run build:browser` to create a standalone js file in `dist` Resolves cookpete/react-player#35 Also fully resolves cookpete/react-player#38
Run `npm run build:browser` to create a standalone js file in `dist` Resolves cookpete/react-player#35 Also fully resolves cookpete/react-player#38
Run `npm run build:browser` to create a standalone js file in `dist` Resolves cookpete/react-player#35 Also fully resolves cookpete/react-player#38
Run `npm run build:browser` to create a standalone js file in `dist` Resolves cookpete/react-player#35 Also fully resolves cookpete/react-player#38
Run `npm run build:browser` to create a standalone js file in `dist` Resolves cookpete/react-player#35 Also fully resolves cookpete/react-player#38
Run `npm run build:browser` to create a standalone js file in `dist` Resolves cookpete/react-player#35 Also fully resolves cookpete/react-player#38
Hey Pete,
This is a truly awesome project. Wow!
I would like to integrate this into my Meteor/React web application, and I think that it needs to be able to work with Browserify. Any suggestions on how I can make this work?
Best,
Nathan
The text was updated successfully, but these errors were encountered: