"next-js-player" is video player that supports both react and next js(i.e pages router and app router)
Clone This Repo and Move Into The Project Folder:
git clone https://github.com/CareerDevelopmentHub/Next-Js-Player.git
cd Next-Js-Player
Install All The Dependencies:
npm i or yarn
Start The Local Server:
npm run dev or yarn dev
- Run the command below to install next-js-player
npm i next-js-player
or
yarn add next-js-player
- Run the command below to install react-icons
npm i react-icons
or
yarn add react-icons
- Run the command below to install tailwindcss, if not installed
npm install -D tailwindcss
npx tailwindcss init
or
yarn add -D tailwindcss
yarn tailwindcss init
- Add the below css to the globals.css (for Next Js) or to the index.css/App.css (for React Js)
@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}
.player-controls {
bottom: -4rem !important;
}
.video-wraper:hover > .player-controls {
bottom: -15px !important;
}
::-webkit-media-controls {
display: none !important;
}
video::-webkit-media-controls {
display: none !important;
}
video::-webkit-media-controls-enclosure {
display: none !important;
}
- Add the configs below to install tailwindcss.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
"./src/components/**/*.{js,ts,jsx,tsx,mdx}",
"./src/app/**/*.{js,ts,jsx,tsx,mdx}",
"./node_modules/next-js-player/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
},
},
},
plugins: [],
};
- Add the configs below to install tailwindcss.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{js,jsx,ts,tsx}"],
theme: { extend: {}},
plugins: [],
};
import Player from "next-js-player";
export default function Home() {
return (
<main>
<Player source={"<source url/path>"} width={100} />
</main>
);
}
Pass these attributes and values to the "Player" component.
Type | Attributes | Values |
---|---|---|
string | source | or locale source of the video |
number | width | <value in %> and by default value is 100% |
boolean | loop | by default false |