customvidplayer 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Section.d.ts +15 -0
- package/dist/components/Section.js +19 -0
- package/dist/components/ThemeProvider.d.ts +17 -0
- package/dist/components/ThemeProvider.js +30 -0
- package/dist/components/VideoPlayer.d.ts +26 -0
- package/dist/components/VideoPlayer.js +89 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +12 -0
- package/package.json +3 -2
- package/tsconfig.json +9 -7
@@ -0,0 +1,15 @@
|
|
1
|
+
export default Section;
|
2
|
+
declare function Section({ name, timestamp, onClick }: {
|
3
|
+
name: any;
|
4
|
+
timestamp: any;
|
5
|
+
onClick: any;
|
6
|
+
}): React.JSX.Element;
|
7
|
+
declare namespace Section {
|
8
|
+
namespace propTypes {
|
9
|
+
const name: PropTypes.Validator<string>;
|
10
|
+
const timestamp: PropTypes.Validator<number>;
|
11
|
+
const onClick: PropTypes.Validator<(...args: any[]) => any>;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
import React from "react";
|
15
|
+
import PropTypes from "prop-types";
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
var react_1 = __importDefault(require("react"));
|
7
|
+
var prop_types_1 = __importDefault(require("prop-types"));
|
8
|
+
var Section = function (_a) {
|
9
|
+
var name = _a.name, timestamp = _a.timestamp, onClick = _a.onClick;
|
10
|
+
return (<div className="section" onClick={function () { return onClick(timestamp); }}>
|
11
|
+
{name}
|
12
|
+
</div>);
|
13
|
+
};
|
14
|
+
Section.propTypes = {
|
15
|
+
name: prop_types_1.default.string.isRequired,
|
16
|
+
timestamp: prop_types_1.default.number.isRequired,
|
17
|
+
onClick: prop_types_1.default.func.isRequired,
|
18
|
+
};
|
19
|
+
exports.default = Section;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export default ThemeProvider;
|
2
|
+
declare function ThemeProvider({ theme, children }: {
|
3
|
+
theme: any;
|
4
|
+
children: any;
|
5
|
+
}): React.JSX.Element;
|
6
|
+
declare namespace ThemeProvider {
|
7
|
+
namespace propTypes {
|
8
|
+
const theme: PropTypes.Requireable<object>;
|
9
|
+
const children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
10
|
+
}
|
11
|
+
namespace defaultProps {
|
12
|
+
const theme_1: {};
|
13
|
+
export { theme_1 as theme };
|
14
|
+
}
|
15
|
+
}
|
16
|
+
import React from "react";
|
17
|
+
import PropTypes from "prop-types";
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
var react_1 = __importDefault(require("react"));
|
18
|
+
var prop_types_1 = __importDefault(require("prop-types"));
|
19
|
+
var ThemeProvider = function (_a) {
|
20
|
+
var theme = _a.theme, children = _a.children;
|
21
|
+
return (<div style={__assign({}, theme)}>{children}</div>);
|
22
|
+
};
|
23
|
+
ThemeProvider.propTypes = {
|
24
|
+
theme: prop_types_1.default.object,
|
25
|
+
children: prop_types_1.default.node.isRequired,
|
26
|
+
};
|
27
|
+
ThemeProvider.defaultProps = {
|
28
|
+
theme: {},
|
29
|
+
};
|
30
|
+
exports.default = ThemeProvider;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
export default VideoPlayer;
|
2
|
+
declare function VideoPlayer({ videoSrc, sections, onSectionChange, theme }: {
|
3
|
+
videoSrc: any;
|
4
|
+
sections: any;
|
5
|
+
onSectionChange: any;
|
6
|
+
theme: any;
|
7
|
+
}): React.JSX.Element;
|
8
|
+
declare namespace VideoPlayer {
|
9
|
+
namespace propTypes {
|
10
|
+
const videoSrc: PropTypes.Validator<string>;
|
11
|
+
const sections: PropTypes.Validator<(PropTypes.InferProps<{
|
12
|
+
name: PropTypes.Validator<string>;
|
13
|
+
timestamp: PropTypes.Validator<number>;
|
14
|
+
}> | null | undefined)[]>;
|
15
|
+
const onSectionChange: PropTypes.Requireable<(...args: any[]) => any>;
|
16
|
+
const theme: PropTypes.Requireable<object>;
|
17
|
+
}
|
18
|
+
namespace defaultProps {
|
19
|
+
const theme_1: {};
|
20
|
+
export { theme_1 as theme };
|
21
|
+
const onSectionChange_1: null;
|
22
|
+
export { onSectionChange_1 as onSectionChange };
|
23
|
+
}
|
24
|
+
}
|
25
|
+
import React from "react";
|
26
|
+
import PropTypes from "prop-types";
|
@@ -0,0 +1,89 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
14
|
+
if (k2 === undefined) k2 = k;
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
18
|
+
}
|
19
|
+
Object.defineProperty(o, k2, desc);
|
20
|
+
}) : (function(o, m, k, k2) {
|
21
|
+
if (k2 === undefined) k2 = k;
|
22
|
+
o[k2] = m[k];
|
23
|
+
}));
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
26
|
+
}) : function(o, v) {
|
27
|
+
o["default"] = v;
|
28
|
+
});
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
30
|
+
if (mod && mod.__esModule) return mod;
|
31
|
+
var result = {};
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
33
|
+
__setModuleDefault(result, mod);
|
34
|
+
return result;
|
35
|
+
};
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
38
|
+
};
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
40
|
+
var react_1 = __importStar(require("react"));
|
41
|
+
var prop_types_1 = __importDefault(require("prop-types"));
|
42
|
+
require("./../styles/defaultTheme.css");
|
43
|
+
var VideoPlayer = function (_a) {
|
44
|
+
var videoSrc = _a.videoSrc, sections = _a.sections, onSectionChange = _a.onSectionChange, theme = _a.theme;
|
45
|
+
var videoRef = (0, react_1.useRef)(null);
|
46
|
+
var _b = (0, react_1.useState)(0), currentSectionIndex = _b[0], setCurrentSectionIndex = _b[1];
|
47
|
+
var skipToNextSection = function () {
|
48
|
+
if (currentSectionIndex < sections.length - 1) {
|
49
|
+
var nextSection = sections[currentSectionIndex + 1];
|
50
|
+
videoRef.current.currentTime = nextSection.timestamp;
|
51
|
+
setCurrentSectionIndex(currentSectionIndex + 1);
|
52
|
+
if (onSectionChange)
|
53
|
+
onSectionChange(nextSection);
|
54
|
+
}
|
55
|
+
};
|
56
|
+
var handleTimeUpdate = function () {
|
57
|
+
var currentTime = videoRef.current.currentTime;
|
58
|
+
var currentSection = sections.find(function (section, index) {
|
59
|
+
return currentTime >= section.timestamp &&
|
60
|
+
(index === sections.length - 1 || currentTime < sections[index + 1].timestamp);
|
61
|
+
});
|
62
|
+
if (currentSection && sections[currentSectionIndex] !== currentSection) {
|
63
|
+
var newIndex = sections.indexOf(currentSection);
|
64
|
+
setCurrentSectionIndex(newIndex);
|
65
|
+
if (onSectionChange)
|
66
|
+
onSectionChange(currentSection);
|
67
|
+
}
|
68
|
+
};
|
69
|
+
return (<div className="video-player" style={__assign({}, theme)}>
|
70
|
+
<video src={videoSrc} controls ref={videoRef} onTimeUpdate={handleTimeUpdate} className="video-element"/>
|
71
|
+
<button onClick={skipToNextSection} className="skip-button">
|
72
|
+
Skip
|
73
|
+
</button>
|
74
|
+
</div>);
|
75
|
+
};
|
76
|
+
VideoPlayer.propTypes = {
|
77
|
+
videoSrc: prop_types_1.default.string.isRequired,
|
78
|
+
sections: prop_types_1.default.arrayOf(prop_types_1.default.shape({
|
79
|
+
name: prop_types_1.default.string.isRequired,
|
80
|
+
timestamp: prop_types_1.default.number.isRequired,
|
81
|
+
})).isRequired,
|
82
|
+
onSectionChange: prop_types_1.default.func,
|
83
|
+
theme: prop_types_1.default.object,
|
84
|
+
};
|
85
|
+
VideoPlayer.defaultProps = {
|
86
|
+
theme: {},
|
87
|
+
onSectionChange: null,
|
88
|
+
};
|
89
|
+
exports.default = VideoPlayer;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.ThemeProvider = exports.Section = exports.VideoPlayer = void 0;
|
7
|
+
var VideoPlayer_1 = require("./components/VideoPlayer");
|
8
|
+
Object.defineProperty(exports, "VideoPlayer", { enumerable: true, get: function () { return __importDefault(VideoPlayer_1).default; } });
|
9
|
+
var Section_1 = require("./components/Section");
|
10
|
+
Object.defineProperty(exports, "Section", { enumerable: true, get: function () { return __importDefault(Section_1).default; } });
|
11
|
+
var ThemeProvider_1 = require("./components/ThemeProvider");
|
12
|
+
Object.defineProperty(exports, "ThemeProvider", { enumerable: true, get: function () { return __importDefault(ThemeProvider_1).default; } });
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "customvidplayer",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.9",
|
4
4
|
"description": "Customizable video player with section navigation and theming.",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -10,11 +10,12 @@
|
|
10
10
|
"test": "jest"
|
11
11
|
},
|
12
12
|
"dependencies": {
|
13
|
-
"@types/react": "^18.3.12",
|
14
13
|
"prop-types": "^15.8.1",
|
15
14
|
"react": "^18.0.0"
|
16
15
|
},
|
17
16
|
"devDependencies": {
|
17
|
+
"@types/react": "^18.3.12",
|
18
|
+
"@types/react-dom": "^18.3.1",
|
18
19
|
"jest": "^29.0.0",
|
19
20
|
"typescript": "^4.9.5",
|
20
21
|
"webpack": "^5.75.0"
|
package/tsconfig.json
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
|
-
"
|
4
|
-
"
|
5
|
-
"
|
3
|
+
"outDir": "./dist",
|
4
|
+
"rootDir": "./src",
|
5
|
+
"declaration": true,
|
6
|
+
"module": "CommonJS",
|
7
|
+
"target": "ES5",
|
6
8
|
"strict": true,
|
7
9
|
"esModuleInterop": true,
|
8
|
-
"
|
9
|
-
"
|
10
|
-
"outDir": "./dist"
|
10
|
+
"skipLibCheck": true,
|
11
|
+
"allowJs": true
|
11
12
|
},
|
12
|
-
"include": ["src/**/*"]
|
13
|
+
"include": ["src/**/*"],
|
14
|
+
"exclude": ["node_modules", "dist"]
|
13
15
|
}
|
14
16
|
|