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

Video.js and React Guide #3818

Closed
misteroneill opened this issue Dec 1, 2016 · 5 comments
Closed

Video.js and React Guide #3818

misteroneill opened this issue Dec 1, 2016 · 5 comments

Comments

@misteroneill
Copy link
Member

We should write a guide for using Video.js and React and add it to the FAQ. This topic has come up multiple times.

@kocoten1992
Copy link
Contributor

Any plan for vue js 👍 ?

@misteroneill
Copy link
Member Author

Maybe. If it seems to be popular enough. But I would imagine many of the principles carry across frameworks. It's all the DOM in the end.

@gkatsev
Copy link
Member

gkatsev commented Dec 2, 2016

If someone were to write such a guide, we'd definitely be interested but the core team isn't really familiar with vuejs at the moment.

@revolunet
Copy link
Contributor

here's a basic react implementation.

import React from 'react';
import ReactDOM from 'react-dom';

import videojs from 'video.js'
require('!style-loader!css-loader!video.js/dist/video-js.css')

class VideoPlayer extends React.Component {
  componentDidMount() {
    // see https://github.com/videojs/video.js/blob/master/docs/guides/options.md
    const options = {
      sources: [{
        src: '/path/to/video.mp4',
        type: 'video/mp4'
      }]
    }

    const videoNode = ReactDOM.findDOMNode(this).querySelector('video');

    this.player = videojs(videoNode, options, function onPlayerReady() {
      console.log('onPlayerReady', this)
    });

  }
  componentWillUnmount() {
    if (this.player) {
      this.player.dispose()
    }
  }
  render() {
    return (
      <div data-vjs-player>
        <video className="video-js"></video>
      </div>
    )
  }
}

@gkatsev
Copy link
Member

gkatsev commented Jan 2, 2018

We have a version of one.

@gkatsev gkatsev closed this as completed Jan 2, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants