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

Using videojs-vr plugin with react #46

Closed
zhumeisongsong opened this issue Jan 18, 2018 · 3 comments
Closed

Using videojs-vr plugin with react #46

zhumeisongsong opened this issue Jan 18, 2018 · 3 comments

Comments

@zhumeisongsong
Copy link

zhumeisongsong commented Jan 18, 2018

It works well in pc but fail at ios10 safiri ,the screen is black.
here is the test link http://120.24.19.157:1233/

the main code

import React from 'react';
import videojs from 'video.js'
import 'videojs-vr'
import '../../../node_modules/video.js/dist/video-js.css'
import '../../../node_modules/videojs-vr/dist/videojs-vr.css'

export default class VideoPlayer extends React.Component {
  componentDidMount() {
  this.player = videojs(this.videoNode, this.props, function onPlayerReady() {
  console.log('onPlayerReady', this)
  const player = this
  player.mediainfo = player.mediainfo || {}
  player.mediainfo.projection = '360'
  player.vr({
    projection: 'AUTO',
    debug: true,
    forceCardboard: false
  })
})
}

// destroy player on unmount
componentWillUnmount() {
  if (this.player) {
    this.player.dispose()
  }
}

  // wrap the player in a div with a `data-vjs-player` attribute
  // so videojs won't create additional wrapper in the DOM
  // see https://github.com/videojs/video.js/pull/3856
  render() {
    return (
      <div data-vjs-player>
        <video ref={ node => this.videoNode = node } className="video-js"></video>
      </div>
    )
  }
}

my package.json

{
  "name": "vr",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "1.1.0",
    "videojs-vr": "^1.0.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

Anyone who solved this, please tell me your solution,thanks! It‘s hurry for me...

@brandonocasey
Copy link
Contributor

I Don't think this is a react problem. This is likely a cross origin problem. Can you try the following:

  • test to make sure an mp4 works
  • try with version 1.1.0, as there have been several fixes for HLS on iOS and desktop safari
  • Add crossorigin="anonymous" to the video dom element

@brandonocasey
Copy link
Contributor

brandonocasey commented Mar 22, 2018

Feel free to create another issue if this is still an issue

@johnflux
Copy link

johnflux commented Jul 22, 2018

Note that in react it is crossOrigin="anonymous"

e.g

render() {
    return (
      <div>
        <div data-vjs-player style={{ width: '100%', height: '500px' }}>
          <video ref={node => (this.videoNode = node)} className="video-js vjs-default-skin" crossOrigin="anonymous" />
        </div>
      </div>
    );
  }

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

No branches or pull requests

3 participants