Start adding video player #10

This commit is contained in:
prayag17 committed 2023-05-08 18:11:33 +05:30
1 parent dd4f5bab30
commit 377f926fea
13 files changed
+2659 -115

No files matched your search

+1
View File
@@ -63,6 +63,7 @@ export const AppBar = () => {
if (
location.pathname.includes("login") ||
location.pathname.includes("setup") ||
location.pathname.includes("player") ||
location.pathname === "/"
) {
setDisplay(false);
@@ -37,6 +37,7 @@ export const ArtistAlbum = ({ user, album, boxProps }) => {
});
return result.data;
},
networkMode: "always",
});
const handleLikingTrack = async (track) => {
+1 -5
View File
@@ -93,6 +93,7 @@ export const SideMenu = ({}) => {
if (
location.pathname.includes("login") ||
location.pathname.includes("setup") ||
location.pathname.includes("player") ||
location.pathname === "/"
) {
setDisplay(false);
@@ -275,8 +276,3 @@ export const SideMenu = ({}) => {
);
}
};
// SideMenu.propTypes = {
// skeleton: PropTypes.bool.isRequired,
// data: PropTypes.array.isRequired,
// };
+56
View File
@@ -0,0 +1,56 @@
/** @format */
import React from "react";
import videojs from "video.js";
import "./video.module.scss";
export const VideoJS = (props) => {
const videoRef = React.useRef(null);
const playerRef = React.useRef(null);
const { options, onReady } = props;
React.useEffect(() => {
// Make sure Video.js player is only initialized once
if (!playerRef.current) {
// The Video.js player needs to be _inside_ the component el for React 18 Strict Mode.
const videoElement = document.createElement("video-js");
videoElement.classList.add("vjs-big-play-centered");
videoRef.current.appendChild(videoElement);
const player = (playerRef.current = videojs(
videoElement,
options,
() => {
videojs.log("player is ready");
onReady && onReady(player);
},
));
} else {
const player = playerRef.current;
player.autoplay(options.autoplay);
player.src(options.sources);
}
}, [options, videoRef]);
// Dispose the Video.js player when the functional component unmounts
React.useEffect(() => {
const player = playerRef.current;
return () => {
if (player && !player.isDisposed()) {
player.dispose();
playerRef.current = null;
}
};
}, [playerRef]);
return (
<div data-vjs-player>
<div ref={videoRef} />
</div>
);
};
export default VideoJS;
File diff suppressed because it is too large. Load diff