mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 23:23:18 -08:00
修复切换画质bug
This commit is contained in:
1 parent
d4b9fc4d29
commit
88533c1023
8 files changed
+116
-138
No files matched your search
@@ -10,56 +10,54 @@ const replace = require('rollup-plugin-replace');
|
||||
const svgo = require('rollup-plugin-svgo');
|
||||
const { uglify } = require('rollup-plugin-uglify');
|
||||
const { version, homepage, name } = require('./package.json');
|
||||
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
|
||||
const banner =
|
||||
'/*!\n' +
|
||||
` * ${name}.js v${version}\n` +
|
||||
` * Github: ${homepage}\n` +
|
||||
` * (c) 2017-${new Date().getFullYear()} Harvey Zack\n` +
|
||||
' * Released under the MIT License.\n' +
|
||||
' */\n';
|
||||
'/*!\n' +
|
||||
` * ${name}.js v${version}\n` +
|
||||
` * Github: ${homepage}\n` +
|
||||
` * (c) 2017-${new Date().getFullYear()} Harvey Zack\n` +
|
||||
' * Released under the MIT License.\n' +
|
||||
' */\n';
|
||||
|
||||
export default {
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
name: name,
|
||||
file: isProd ? `dist/${name}.js` : path.join(process.cwd(), '../../', `docs/lab/js/${name}.js`),
|
||||
format: 'umd',
|
||||
exports: 'named'
|
||||
},
|
||||
plugins: [
|
||||
eslint({
|
||||
exclude: [
|
||||
'node_modules/**',
|
||||
'src/**/*.scss',
|
||||
'src/**/*.svg'
|
||||
]
|
||||
}),
|
||||
postcss({
|
||||
plugins: [autoprefixer, cssnano],
|
||||
extract: isProd ? `dist/${name}.css` : path.join(process.cwd(), '../../', `docs/lab/css/${name}.css`)
|
||||
}),
|
||||
nodeResolve(),
|
||||
commonjs(),
|
||||
babel({
|
||||
runtimeHelpers: true,
|
||||
exclude: 'node_modules/**',
|
||||
presets: [['@babel/env', { modules: false }]],
|
||||
plugins: ['@babel/plugin-external-helpers', '@babel/plugin-transform-runtime']
|
||||
}),
|
||||
svgo({
|
||||
raw: true
|
||||
}),
|
||||
replace({
|
||||
exclude: 'node_modules/**',
|
||||
__ENV__: JSON.stringify(process.env.NODE_ENV || 'development'),
|
||||
__VERSION__: version
|
||||
}),
|
||||
isProd && uglify({
|
||||
output: {
|
||||
preamble: banner
|
||||
}
|
||||
})
|
||||
]
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
name,
|
||||
file: isProd ? `dist/${name}.js` : path.join(process.cwd(), '../../', `docs/lab/js/${name}.js`),
|
||||
format: 'umd',
|
||||
exports: 'named',
|
||||
},
|
||||
plugins: [
|
||||
eslint({
|
||||
exclude: ['node_modules/**', 'src/**/*.scss', 'src/**/*.svg'],
|
||||
}),
|
||||
postcss({
|
||||
plugins: [autoprefixer, cssnano],
|
||||
extract: isProd ? `dist/${name}.css` : path.join(process.cwd(), '../../', `docs/lab/css/${name}.css`),
|
||||
}),
|
||||
nodeResolve(),
|
||||
commonjs(),
|
||||
babel({
|
||||
runtimeHelpers: true,
|
||||
exclude: 'node_modules/**',
|
||||
presets: [['@babel/env', { modules: false }]],
|
||||
plugins: ['@babel/plugin-external-helpers', '@babel/plugin-transform-runtime'],
|
||||
}),
|
||||
svgo({
|
||||
raw: true,
|
||||
}),
|
||||
replace({
|
||||
exclude: 'node_modules/**',
|
||||
__ENV__: JSON.stringify(process.env.NODE_ENV || 'development'),
|
||||
__VERSION__: version,
|
||||
}),
|
||||
isProd &&
|
||||
uglify({
|
||||
output: {
|
||||
preamble: banner,
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
@@ -10,56 +10,54 @@ const replace = require('rollup-plugin-replace');
|
||||
const svgo = require('rollup-plugin-svgo');
|
||||
const { uglify } = require('rollup-plugin-uglify');
|
||||
const { version, homepage, name } = require('./package.json');
|
||||
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
|
||||
const banner =
|
||||
'/*!\n' +
|
||||
` * ${name}.js v${version}\n` +
|
||||
` * Github: ${homepage}\n` +
|
||||
` * (c) 2017-${new Date().getFullYear()} Harvey Zack\n` +
|
||||
' * Released under the MIT License.\n' +
|
||||
' */\n';
|
||||
'/*!\n' +
|
||||
` * ${name}.js v${version}\n` +
|
||||
` * Github: ${homepage}\n` +
|
||||
` * (c) 2017-${new Date().getFullYear()} Harvey Zack\n` +
|
||||
' * Released under the MIT License.\n' +
|
||||
' */\n';
|
||||
|
||||
export default {
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
name: name,
|
||||
file: isProd ? `dist/${name}.js` : path.join(process.cwd(), '../../', `docs/lab/js/${name}.js`),
|
||||
format: 'umd',
|
||||
exports: 'named'
|
||||
},
|
||||
plugins: [
|
||||
eslint({
|
||||
exclude: [
|
||||
'node_modules/**',
|
||||
'src/**/*.scss',
|
||||
'src/**/*.svg'
|
||||
]
|
||||
}),
|
||||
postcss({
|
||||
plugins: [autoprefixer, cssnano],
|
||||
extract: isProd ? `dist/${name}.css` : path.join(process.cwd(), '../../', `docs/lab/css/${name}.css`)
|
||||
}),
|
||||
nodeResolve(),
|
||||
commonjs(),
|
||||
babel({
|
||||
runtimeHelpers: true,
|
||||
exclude: 'node_modules/**',
|
||||
presets: [['@babel/env', { modules: false }]],
|
||||
plugins: ['@babel/plugin-external-helpers', '@babel/plugin-transform-runtime']
|
||||
}),
|
||||
svgo({
|
||||
raw: true
|
||||
}),
|
||||
replace({
|
||||
exclude: 'node_modules/**',
|
||||
__ENV__: JSON.stringify(process.env.NODE_ENV || 'development'),
|
||||
__VERSION__: version
|
||||
}),
|
||||
isProd && uglify({
|
||||
output: {
|
||||
preamble: banner
|
||||
}
|
||||
})
|
||||
]
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
name,
|
||||
file: isProd ? `dist/${name}.js` : path.join(process.cwd(), '../../', `docs/lab/js/${name}.js`),
|
||||
format: 'umd',
|
||||
exports: 'named',
|
||||
},
|
||||
plugins: [
|
||||
eslint({
|
||||
exclude: ['node_modules/**', 'src/**/*.scss', 'src/**/*.svg'],
|
||||
}),
|
||||
postcss({
|
||||
plugins: [autoprefixer, cssnano],
|
||||
extract: isProd ? `dist/${name}.css` : path.join(process.cwd(), '../../', `docs/lab/css/${name}.css`),
|
||||
}),
|
||||
nodeResolve(),
|
||||
commonjs(),
|
||||
babel({
|
||||
runtimeHelpers: true,
|
||||
exclude: 'node_modules/**',
|
||||
presets: [['@babel/env', { modules: false }]],
|
||||
plugins: ['@babel/plugin-external-helpers', '@babel/plugin-transform-runtime'],
|
||||
}),
|
||||
svgo({
|
||||
raw: true,
|
||||
}),
|
||||
replace({
|
||||
exclude: 'node_modules/**',
|
||||
__ENV__: JSON.stringify(process.env.NODE_ENV || 'development'),
|
||||
__VERSION__: version,
|
||||
}),
|
||||
isProd &&
|
||||
uglify({
|
||||
output: {
|
||||
preamble: banner,
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
@@ -34,7 +34,7 @@ export default class Quality {
|
||||
const index = Number(event.target.dataset.index);
|
||||
const { url, name } = option.quality[index];
|
||||
if (url && name && this.playIndex !== index) {
|
||||
player.switch(url, name);
|
||||
player.switchQuality(url, name);
|
||||
$qualityName.innerHTML = name;
|
||||
this.playIndex = index;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import seekMix from './seekMix';
|
||||
import volumeMix from './volumeMix';
|
||||
import currentTimeMix from './currentTimeMix';
|
||||
import durationMix from './durationMix';
|
||||
import switchMix from './switchMix';
|
||||
import switchQualityMix from './switchQualityMix';
|
||||
import playbackRateMix from './playbackRateMix';
|
||||
import aspectRatioMix from './aspectRatioMix';
|
||||
import screenshotMix from './screenshotMix';
|
||||
@@ -32,7 +32,7 @@ export default class Player {
|
||||
volumeMix(art, this);
|
||||
currentTimeMix(art, this);
|
||||
durationMix(art, this);
|
||||
switchMix(art, this);
|
||||
switchQualityMix(art, this);
|
||||
playbackRateMix(art, this);
|
||||
aspectRatioMix(art, this);
|
||||
screenshotMix(art, this);
|
||||
|
||||
@@ -32,16 +32,6 @@ function nativePip(art, player) {
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(player, 'pipToggle', {
|
||||
value: () => {
|
||||
if (player.pipState) {
|
||||
player.pipExit();
|
||||
} else {
|
||||
player.pipEnabled();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
proxy($video, 'enterpictureinpicture', () => {
|
||||
art.emit('pipEnabled');
|
||||
});
|
||||
@@ -117,6 +107,14 @@ function customPip(art, player) {
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export default function pipMix(art, player) {
|
||||
if (document.pictureInPictureEnabled) {
|
||||
nativePip(art, player);
|
||||
} else {
|
||||
customPip(art, player);
|
||||
}
|
||||
|
||||
Object.defineProperty(player, 'pipToggle', {
|
||||
value: () => {
|
||||
@@ -128,11 +126,3 @@ function customPip(art, player) {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export default function pipMix(art, player) {
|
||||
if (document.pictureInPictureEnabled) {
|
||||
nativePip(art, player);
|
||||
} else {
|
||||
customPip(art, player);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,13 +3,13 @@ export default function switchMix(art, player) {
|
||||
refs: { $video },
|
||||
i18n,
|
||||
notice,
|
||||
isPlaying,
|
||||
option,
|
||||
} = art;
|
||||
|
||||
Object.defineProperty(player, 'switch', {
|
||||
Object.defineProperty(player, 'switchQuality', {
|
||||
value: (url, name = 'unknown') => {
|
||||
if (url !== option.url) {
|
||||
const { isPlaying } = art;
|
||||
const { currentTime } = player;
|
||||
art.emit('beforeMountUrl', url);
|
||||
$video.src = player.mountUrl(url);
|
||||
Reference in new issue
Block a user