mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 00:31:20 -08:00
update sw.js
This commit is contained in:
1 parent
b53deb5ad8
commit
227268ecda
12 files changed
+61
-114
No files matched your search
@@ -2,29 +2,18 @@ import { def } from '../utils';
|
||||
|
||||
export default function exclusiveMix(art) {
|
||||
const sizeProps = ['mini', 'pip', 'fullscreen', 'fullscreenWeb'];
|
||||
|
||||
function exclusive(props) {
|
||||
for (let index = 0; index < props.length; index++) {
|
||||
const name = props[index];
|
||||
art.on(name, () => {
|
||||
if (art[name]) {
|
||||
props
|
||||
.filter((item) => item !== name)
|
||||
.forEach((item) => {
|
||||
if (art[item]) {
|
||||
art[item] = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exclusive(sizeProps);
|
||||
|
||||
def(art, 'normalSize', {
|
||||
get() {
|
||||
return sizeProps.every((name) => !art[name]);
|
||||
},
|
||||
set(name) {
|
||||
sizeProps
|
||||
.filter((item) => item !== name)
|
||||
.forEach((item) => {
|
||||
if (art[item]) {
|
||||
art[item] = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -15,19 +15,20 @@ const nativeScreenfull = (art) => {
|
||||
},
|
||||
set(value) {
|
||||
if (value) {
|
||||
art.normalSize = 'fullscreen';
|
||||
art.aspectRatioReset = true;
|
||||
art.autoSize = false;
|
||||
screenfull.request($player).then(() => {
|
||||
addClass($player, 'art-fullscreen');
|
||||
art.aspectRatioReset = true;
|
||||
art.autoSize = false;
|
||||
art.emit('resize');
|
||||
art.emit('fullscreen', true);
|
||||
notice.show = '';
|
||||
});
|
||||
} else {
|
||||
art.aspectRatioReset = true;
|
||||
art.autoSize = art.option.autoSize;
|
||||
screenfull.exit().then(() => {
|
||||
removeClass($player, 'art-fullscreen');
|
||||
art.aspectRatioReset = true;
|
||||
art.autoSize = art.option.autoSize;
|
||||
art.emit('resize');
|
||||
art.emit('fullscreen');
|
||||
notice.show = '';
|
||||
@@ -49,6 +50,7 @@ const webkitScreenfull = (art) => {
|
||||
},
|
||||
set(value) {
|
||||
if (value) {
|
||||
art.normalSize = 'fullscreen';
|
||||
$video.webkitEnterFullscreen();
|
||||
art.emit('fullscreen', true);
|
||||
notice.show = '';
|
||||
|
||||
@@ -12,6 +12,7 @@ export default function fullscreenWebMix(art) {
|
||||
},
|
||||
set(value) {
|
||||
if (value) {
|
||||
art.normalSize = 'fullscreenWeb';
|
||||
addClass($player, 'art-fullscreen-web');
|
||||
art.aspectRatioReset = true;
|
||||
art.autoSize = false;
|
||||
|
||||
@@ -55,6 +55,7 @@ export default function miniMix(art) {
|
||||
},
|
||||
set(value) {
|
||||
if (value) {
|
||||
art.normalSize = 'mini';
|
||||
art.autoSize = false;
|
||||
cacheStyle = $player.style.cssText;
|
||||
addClass($player, 'art-mini');
|
||||
|
||||
@@ -15,6 +15,7 @@ function nativePip(art) {
|
||||
},
|
||||
set(value) {
|
||||
if (value) {
|
||||
art.normalSize = 'pip';
|
||||
$video.requestPictureInPicture().catch((err) => {
|
||||
notice.show = err;
|
||||
throw err;
|
||||
@@ -48,6 +49,7 @@ function webkitPip(art) {
|
||||
},
|
||||
set(value) {
|
||||
if (value) {
|
||||
art.normalSize = 'pip';
|
||||
$video.webkitSetPresentationMode('picture-in-picture');
|
||||
art.emit('pip', true);
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user