Skip to content

Commit f66066d

Browse files
committed
Added video zoom mode, auto play
1 parent cdc59d6 commit f66066d

File tree

18 files changed

+25151
-24396
lines changed

18 files changed

+25151
-24396
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,11 @@ The following attributes come from the `option` property configuration item
7979

8080
| Parameter | Description | type | Default value |
8181
| ------------------- | ------------------------------------------------------------ | ------------------------- | ------------- |
82-
| height | The height of the video container (**required**) | `number` | required |
8382
| videoSrc | Video address (**required**) | `string` | required |
83+
| mode | Video zoom mode | `scaleToFill`(Does not maintain the aspect ratio to scale the video),`widthFix`(The width is unchanged, and the height changes automatically, keeping the aspect ratio of the original video unchanged),`heightFix`(When the height is unchanged, the width changes automatically, keeping the aspect ratio of the original video unchanged) | `scaleToFill` |
84+
| height | The height of the video container | `number` | - |
8485
| width | The width of the video container | `number` | - |
86+
| autoPlay | Video autoplay | `boolean` | false |
8587
| theme | theme | `string` | \#ffb821 |
8688
| poster | Video cover image | `string` | - |
8789
| setEndPlayContent | Customize what is displayed at the end of the video | `React.ReactNode` | - |

build/webpack.prod.config.js

Lines changed: 62 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,73 @@
11
const merge = require("webpack-merge");
2+
const CopyWebpackPlugin = require('copy-webpack-plugin');
23
const common = require("./webpack.common.config.js");
34
const path = require("path");
45

56
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
67
const TerserPlugin = require("terser-webpack-plugin");
78

89
module.exports = merge(common, {
9-
mode: "production",
10-
devtool: "",
11-
entry: {
12-
index: "./src/index",
13-
},
14-
output: {
15-
filename: "[name].js",
16-
path: path.resolve(__dirname, "../dist"),
17-
libraryTarget: "commonjs2",
18-
},
19-
optimization: {
20-
minimize: true,
21-
minimizer: [new TerserPlugin()],
22-
},
23-
module: {
24-
rules: [
25-
{
26-
test: /\.css$/,
27-
use: ["style-loader", "css-loader"],
28-
},
29-
{
30-
test: /\.s[ac]ss$/i,
31-
use: [
32-
// Creates `style` nodes from JS strings
33-
"style-loader",
34-
// Translates CSS into CommonJS
35-
"css-loader",
36-
// Compiles Sass to CSS
37-
"sass-loader",
10+
mode: "production",
11+
devtool: "",
12+
entry: {
13+
index: "./src/index",
14+
},
15+
output: {
16+
filename: "[name].js",
17+
path: path.resolve(__dirname, "../dist"),
18+
libraryTarget: "commonjs2",
19+
},
20+
optimization: {
21+
minimize: true,
22+
minimizer: [new TerserPlugin()],
23+
},
24+
module: {
25+
rules: [{
26+
test: /\.css$/,
27+
use: ["style-loader", "css-loader"],
28+
},
29+
{
30+
test: /\.s[ac]ss$/i,
31+
use: [
32+
// Creates `style` nodes from JS strings
33+
"style-loader",
34+
// Translates CSS into CommonJS
35+
"css-loader",
36+
// Compiles Sass to CSS
37+
"sass-loader",
38+
],
39+
},
3840
],
39-
},
40-
],
41-
},
42-
plugins: [new CleanWebpackPlugin()],
43-
externals: {
44-
react: {
45-
root: "React",
46-
commonjs2: "react",
47-
commonjs: "react",
48-
amd: "react",
4941
},
50-
"react-dom": {
51-
root: "ReactDOM",
52-
commonjs2: "react-dom",
53-
commonjs: "react-dom",
54-
amd: "react-dom",
42+
plugins: [new CleanWebpackPlugin(),
43+
new CopyWebpackPlugin({
44+
patterns: [{
45+
from: path.resolve(__dirname, '../package.json'),
46+
},
47+
{
48+
from: path.resolve(__dirname, '../README.md'),
49+
},
50+
{
51+
from: path.resolve(__dirname, '../zh.md'),
52+
},
53+
{
54+
from: path.resolve(__dirname, '../types/index.d.ts'),
55+
},
56+
],
57+
}),
58+
],
59+
externals: {
60+
react: {
61+
root: "React",
62+
commonjs2: "react",
63+
commonjs: "react",
64+
amd: "react",
65+
},
66+
"react-dom": {
67+
root: "ReactDOM",
68+
commonjs2: "react-dom",
69+
commonjs: "react-dom",
70+
amd: "react-dom",
71+
},
5572
},
56-
},
57-
});
73+
});

example/src/app.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { callBackType, JoLPlayerRef, qualityKey } from '@/interface';
2-
import React, { useRef, useEffect, useState } from 'react';
1+
import React, { useRef, useEffect, useState, useMemo } from 'react';
32
import { createRoot } from 'react-dom/client';
3+
import { callBackType, JoLPlayerRef, qualityKey } from 'types';
44
import { JolPlayer } from '../../src/index';
55

66
const AppCompent = () => {
@@ -71,11 +71,14 @@ const AppCompent = () => {
7171
option={{
7272
// videoType: 'hls',
7373
videoSrc:
74-
'https://gs-files.oss-cn-hongkong.aliyuncs.com/okr/prod/file/2021/08/31/540p.mp4',
74+
// 'https://gs-files.oss-cn-hongkong.aliyuncs.com/okr/prod/file/2021/08/31/540p.mp4',
75+
'https://cdn.gudsen.vip/2022/11/14/422e7528fce64f03bf1b378cff393237.mp4',
7576
// 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
76-
// width: 750,
77-
height: 420,
77+
height: 900,
78+
// width: 500,
79+
mode: 'heightFix',
7880
theme: 'red',
81+
autoPlay: true,
7982
poster:
8083
'https://gs-files.oss-cn-hongkong.aliyuncs.com/okr/prod/file/2021/08/31/1080pp.png',
8184
language: 'zh',

0 commit comments

Comments
 (0)