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

React + VideoJS #386

Open
stormofe opened this issue Apr 6, 2022 · 6 comments
Open

React + VideoJS #386

stormofe opened this issue Apr 6, 2022 · 6 comments
Assignees
Labels
🔖3.x v3.x~ related issue 🌐 PanoViewer (v3) Issues related to PanoViewer (View360 v3)

Comments

@stormofe
Copy link

stormofe commented Apr 6, 2022

Description

How can I use React components along with VideoJS like in your example https://naver.github.io/egjs-view360/examples/panoviewer/etc/videojs.html ?

I have components:

export const useVideoJS = (videoJsOptions) => {
	const videoNode = useRef(null)
	const player = useRef(null)

	let changedKey = videoJsOptions.key;

	useEffect(() => {
		player.current = videojs(videoNode.current, videoJsOptions)

		return () => {
			player.current.dispose()
		}
	}, [changedKey])

	const Video = useCallback(
		({ children, ...props }) => {
			return (
				<div data-vjs-player key={changedKey}>
					<video ref={videoNode} className="video-js" {...props}>
						{children}
					</video>
				</div>
			)
		},
		[changedKey],
	)
	return { Video, player: player.current }
}

I use it like

import './App.css';
import { useVideoJS } from './hooks/useVideoJS';

import vid from './source/vid2.mp4'

function App() {

	const video = {
		url: vid,
		subtitlesUrl: vid
	}

	const { Video } = useVideoJS({
		sources: [{ src: video.url }],
		controls: true,
		playbackRates: [0.5, 1, 1.5, 2],
		responsive: true,
		key: 'VideoJS'
	})

	return (
		<div>
			<Video playsInline muted>
				<track
					src={video.subtitlesUrl}
					kind="subtitles"
					srcLang="en"
					label="English"
				/>
			</Video>
		</div>
	);
}

export default App;

and have simple

<PanoViewer
		tag="div"
		id='viewer'
		video={video.src}
		projectionType={PROJECTION_TYPE.EQUIRECTANGULAR}
		useZoom={false}
		onViewChange={e => {}}
		onReady={e =>{}}
		showPolePoint={true}
	>
	</PanoViewer>

Help me please. I have been working on this problem for several days. Nothing works

@WoodNeck
Copy link
Member

WoodNeck commented Apr 14, 2022

Hello @stormofe!
Sorry for the long wait, I missed checking this issue by mistake.
Here's the working demo:

import React from "react";
import videojs from "video.js";
import { PanoViewer } from "@egjs/react-view360";
import "video.js/dist/video-js.css";

export default class VideoJSDemo extends React.Component {
  private _panoViewer: PanoViewer;
  private _videoRef: HTMLVideoElement;

  public componentDidMount() {
    videojs(this._videoRef).ready(() => {
      this._videoRef.style.display = "none";
      this._panoViewer.setVideo(this._videoRef, {
        projectionType: "equirectangular",
      });
    });
  }

  public render() {
    return <div>
      <PanoViewer ref={ref => {
        ref && (this._panoViewer = ref);
      }} id="viewer" data-vjs-player>
        <video ref={ref => {
          ref && (this._videoRef = ref);
        }} className="video-js vjs-fluid vjs-default-skin vjs-big-play-centered vjs-controls-enabled" crossOrigin="anonymous" playsinline={true} controls loop
        style={{ width: "100%", height: "100%" }}>
          <source src="https://naver.github.io/egjs-view360/examples/panoviewer/etc/img/seven.mp4" type="video/mp4" />
          <source src="https://naver.github.io/egjs-view360/examples/panoviewer/etc/img/seven.webm" type="video/webm"></source>
        </video>
      </PanoViewer>
    </div>
  }
}

I promise to add this demo to the next version :)

@WoodNeck WoodNeck self-assigned this Apr 14, 2022
@WoodNeck WoodNeck added the 🌐 PanoViewer (v3) Issues related to PanoViewer (View360 v3) label Apr 14, 2022
@stormofe
Copy link
Author

stormofe commented Apr 14, 2022

Thank you very much for your reply! I was really looking forward to this ;)
Could you please tell me how can I use your development (PanoControls) in this project?
Copy folder 'Common' from repo or install npm package egjs-view360 and use it from there?

@WoodNeck
Copy link
Member

@stormofe
It might be frustrating, but we don't package PanoControl inside @egjs/react-view360
But, like you said, you can copy-paste the source code and use that in your repository :)

You should copy all of those files:

You might have to copy those files too, if you're willing to use the VR

As those files are developed only for our demo, it might be quite burdensome to migrate them.
I'll fix that on the new major version.
Feel free to leave a comment here if there's some issue while migrating.

@stormofe
Copy link
Author

Thanks for the answer.
Hmm, this will be a laborious process. I'll try to do it myself.
Can you please let me know when you plan to release the new major version?

@WoodNeck
Copy link
Member

Well, it's gonna take a while. I have to finish what I'm working on right now.
I think it would take at least 3 months or longer.

@tap2k
Copy link

tap2k commented Oct 12, 2022

I tried using this example code exactly as written and the video does not take up the whole viewport. Am I doing something wrong?

@WoodNeck WoodNeck added the 🔖3.x v3.x~ related issue label Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔖3.x v3.x~ related issue 🌐 PanoViewer (v3) Issues related to PanoViewer (View360 v3)
Projects
None yet
Development

No branches or pull requests

3 participants