customvidplayer 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.babelrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "presets": [
3
+ "@babel/preset-env",
4
+ "@babel/preset-react"
5
+ ]
6
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _fa = require("react-icons/fa");
10
+ require("./CVPlayer.css");
11
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
12
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
13
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
14
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
16
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
17
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
18
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
19
+ // Add your CSS for styling
20
+
21
+ /**
22
+ * Custom Video Player Component
23
+ * @param {Object} props - Component properties
24
+ * @param {string} props.videoSrc - Source URL of the video
25
+ * @param {Array} props.sections - Array of section objects with timestamps
26
+ */
27
+ var CVPlayer = function CVPlayer(_ref) {
28
+ var videoSrc = _ref.videoSrc,
29
+ sections = _ref.sections;
30
+ var _useState = (0, _react.useState)(false),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ isPlaying = _useState2[0],
33
+ setIsPlaying = _useState2[1];
34
+ var videoRef = (0, _react.useRef)(null);
35
+ var togglePlayPause = function togglePlayPause() {
36
+ if (isPlaying) {
37
+ videoRef.current.pause();
38
+ } else {
39
+ videoRef.current.play();
40
+ }
41
+ setIsPlaying(!isPlaying);
42
+ };
43
+ var skipToSection = function skipToSection(timestamp) {
44
+ videoRef.current.currentTime = timestamp;
45
+ videoRef.current.play(); // Optionally play after skipping
46
+ };
47
+ return /*#__PURE__*/_react["default"].createElement("div", {
48
+ className: "cv-player"
49
+ }, /*#__PURE__*/_react["default"].createElement("video", {
50
+ ref: videoRef,
51
+ src: videoSrc,
52
+ onTimeUpdate: function onTimeUpdate() {
53
+ return setCurrentTime(videoRef.current.currentTime);
54
+ },
55
+ controls: true // Optional: adds default video controls
56
+ }), /*#__PURE__*/_react["default"].createElement("div", {
57
+ className: "controls"
58
+ }, /*#__PURE__*/_react["default"].createElement("button", {
59
+ onClick: togglePlayPause
60
+ }, isPlaying ? /*#__PURE__*/_react["default"].createElement(_fa.FaPause, null) : /*#__PURE__*/_react["default"].createElement(_fa.FaPlay, null)), sections.map(function (section, index) {
61
+ return /*#__PURE__*/_react["default"].createElement("button", {
62
+ key: index,
63
+ onClick: function onClick() {
64
+ return skipToSection(section.timestamp);
65
+ }
66
+ }, "Skip to ", section.name);
67
+ })));
68
+ };
69
+ var _default = exports["default"] = CVPlayer;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
+ /**
10
+ * Theme Provider for Custom Video Player
11
+ * @param {Object} props - Component properties
12
+ * @returns {JSX.Element}
13
+ */
14
+ var ThemeProvider = function ThemeProvider(_ref) {
15
+ var children = _ref.children;
16
+ return /*#__PURE__*/_react["default"].createElement("div", {
17
+ className: "theme-provider"
18
+ }, children);
19
+ };
20
+ var _default = exports["default"] = ThemeProvider;
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "CVPlayer", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _CVPlayer["default"];
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ThemeProvider", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _ThemeProvider["default"];
16
+ }
17
+ });
18
+ var _CVPlayer = _interopRequireDefault(require("./CVPlayer"));
19
+ var _ThemeProvider = _interopRequireDefault(require("./ThemeProvider"));
20
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "customvidplayer",
3
+ "version": "0.0.1",
4
+ "description": "A customizable video player with section skipping functionality.",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "npx babel src --out-dir dist"
9
+ },
10
+ "keywords": [
11
+ "video",
12
+ "player",
13
+ "custom",
14
+ "react"
15
+ ],
16
+ "author": "Prewcioo",
17
+ "license": "MIT",
18
+ "dependencies": {
19
+ "@types/react": "^18.3.12",
20
+ "react": "^18.3.1",
21
+ "react-icons": "^5.3.0"
22
+ },
23
+ "devDependencies": {
24
+ "@babel/cli": "^7.25.9",
25
+ "@babel/core": "^7.26.0",
26
+ "@babel/preset-env": "^7.26.0",
27
+ "@babel/preset-react": "^7.25.9",
28
+ "babel-loader": "^8.4.1"
29
+ }
30
+ }
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ declare module 'cvplayerv2' {
3
+ export const CVPlayer: any;
4
+ export const ThemeProvider: any;
5
+ }
File without changes
@@ -0,0 +1,51 @@
1
+ import React, { useState, useRef } from 'react';
2
+ import { FaPlay, FaPause } from 'react-icons/fa';
3
+ import './CVPlayer.css'; // Add your CSS for styling
4
+
5
+ /**
6
+ * Custom Video Player Component
7
+ * @param {Object} props - Component properties
8
+ * @param {string} props.videoSrc - Source URL of the video
9
+ * @param {Array} props.sections - Array of section objects with timestamps
10
+ */
11
+ const CVPlayer = ({ videoSrc, sections }) => {
12
+ const [isPlaying, setIsPlaying] = useState(false);
13
+ const videoRef = useRef(null);
14
+
15
+ const togglePlayPause = () => {
16
+ if (isPlaying) {
17
+ videoRef.current.pause();
18
+ } else {
19
+ videoRef.current.play();
20
+ }
21
+ setIsPlaying(!isPlaying);
22
+ };
23
+
24
+ const skipToSection = (timestamp) => {
25
+ videoRef.current.currentTime = timestamp;
26
+ videoRef.current.play(); // Optionally play after skipping
27
+ };
28
+
29
+ return (
30
+ <div className="cv-player">
31
+ <video
32
+ ref={videoRef}
33
+ src={videoSrc}
34
+ onTimeUpdate={() => setCurrentTime(videoRef.current.currentTime)}
35
+ controls // Optional: adds default video controls
36
+ />
37
+ <div className="controls">
38
+ <button onClick={togglePlayPause}>
39
+ {isPlaying ? <FaPause /> : <FaPlay />}
40
+ </button>
41
+ {sections.map((section, index) => (
42
+ <button key={index} onClick={() => skipToSection(section.timestamp)}>
43
+ Skip to {section.name}
44
+ </button>
45
+ ))}
46
+ </div>
47
+ </div>
48
+ );
49
+ };
50
+
51
+ export default CVPlayer;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * Theme Provider for Custom Video Player
5
+ * @param {Object} props - Component properties
6
+ * @returns {JSX.Element}
7
+ */
8
+ const ThemeProvider = ({ children }) => {
9
+ return (
10
+ <div className="theme-provider">
11
+ {children}
12
+ </div>
13
+ );
14
+ };
15
+
16
+ export default ThemeProvider;
package/src/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import CVPlayer from './CVPlayer';
2
+ import ThemeProvider from './ThemeProvider';
3
+
4
+ export { CVPlayer, ThemeProvider };
@@ -0,0 +1,34 @@
1
+ // webpack.config.js
2
+ const path = require('path');
3
+
4
+ module.exports = {
5
+ entry: './src/index.js', // Your main JavaScript file
6
+ output: {
7
+ path: path.resolve(__dirname, 'dist'),
8
+ filename: 'bundle.js',
9
+ },
10
+ module: {
11
+ rules: [
12
+ {
13
+ test: /\.js$/,
14
+ exclude: /node_modules/,
15
+ use: {
16
+ loader: 'babel-loader',
17
+ },
18
+ },
19
+ {
20
+ test: /\.(js|jsx)$/,
21
+ exclude: /node_modules/,
22
+ use: {
23
+ loader: 'babel-loader',
24
+ options: {
25
+ presets: ['@babel/preset-env', '@babel/preset-react']
26
+ }
27
+ }
28
+ }
29
+ ],
30
+ },
31
+ resolve: {
32
+ extensions: ['.js', '.jsx'] // Ensure .jsx is resolved
33
+ }
34
+ };