React + VideoJS
See original GitHub issueDescription
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
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
React and Video.js
A brief guide to using Video.js with React. ... These are several React and Video.js player implementations and examples. Don't forget to include...
Read more >A sample Video.js with React project - CodeSandbox
A sample Video.js with React project. See https://github.com/videojs/video.js/blob/master/docs/guides/react.md for more info.
Read more >videojs-react-enhanced - npm
React.js wrapper component for Video.js player with handy and powerful features. NOTE: The basic feature is working, but still it's currently ...
Read more >Video.js with React Hooks - Barstool Engineering
js documentation gives an example of how to use Video.js with React but the example uses class based components and is a bit...
Read more >How to use videojs in React | Swift Discovery - onmyway133
Issue #803 import React from 'react'; import videojs from 'video.js' import 'video.js/dist/video-js.css'; export default class VideoPlayer ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @stormofe! Sorry for the long wait, I missed checking this issue by mistake. Here’s the working demo:
I promise to add this demo to the next version 😃
I tried using this example code exactly as written and the video does not take up the whole viewport. Am I doing something wrong?