格式化

This commit is contained in:
Harvey Zack committed 2018-11-21 19:45:44 +08:00
1 parent 0454f785be
commit 203ad0d3a0
75 files changed
+3120 -2904

No files matched your search

+111 -111
View File
@@ -2,137 +2,137 @@ import Draggabilly from 'draggabilly';
import { setStyle, append } from '../utils';
function nativePip(art, player) {
const {
notice,
refs: { $video },
events: { proxy }
} = art;
const {
notice,
refs: { $video },
events: { proxy },
} = art;
$video.disablePictureInPicture = false;
$video.disablePictureInPicture = false;
Object.defineProperty(player, 'pipState', {
get: () => document.pictureInPictureElement
});
Object.defineProperty(player, 'pipState', {
get: () => document.pictureInPictureElement,
});
Object.defineProperty(player, 'pipEnabled', {
value: () => {
$video.requestPictureInPicture().catch(error => {
notice.show(error, true, 3000);
console.warn(error);
});
}
});
Object.defineProperty(player, 'pipEnabled', {
value: () => {
$video.requestPictureInPicture().catch(error => {
notice.show(error, true, 3000);
console.warn(error);
});
},
});
Object.defineProperty(player, 'pipExit', {
value: () => {
document.exitPictureInPicture().catch(error => {
notice.show(error, true, 3000);
console.warn(error);
});
}
});
Object.defineProperty(player, 'pipExit', {
value: () => {
document.exitPictureInPicture().catch(error => {
notice.show(error, true, 3000);
console.warn(error);
});
},
});
Object.defineProperty(player, 'pipToggle', {
value: () => {
if (player.pipState) {
player.pipExit();
} else {
player.pipEnabled();
}
}
});
Object.defineProperty(player, 'pipToggle', {
value: () => {
if (player.pipState) {
player.pipExit();
} else {
player.pipEnabled();
}
},
});
proxy($video, 'enterpictureinpicture', () => {
art.emit('pipEnabled');
});
proxy($video, 'enterpictureinpicture', () => {
art.emit('pipEnabled');
});
proxy($video, 'leavepictureinpicture', () => {
art.emit('pipExit');
if (art.isPlaying) {
player.play();
}
});
proxy($video, 'leavepictureinpicture', () => {
art.emit('pipExit');
if (art.isPlaying) {
player.play();
}
});
}
function customPip(art, player) {
const {
option,
i18n,
refs: { $player, $pipClose, $pipTitle },
events: { destroyEvents, proxy }
} = art;
let cachePos = null;
let draggie = null;
const {
option,
i18n,
refs: { $player, $pipClose, $pipTitle },
events: { destroyEvents, proxy },
} = art;
let cachePos = null;
let draggie = null;
Object.defineProperty(player, 'pipState', {
get: () => $player.classList.contains('artplayer-pip')
});
Object.defineProperty(player, 'pipState', {
get: () => $player.classList.contains('artplayer-pip'),
});
Object.defineProperty(player, 'pipEnabled', {
value: () => {
if (player.autoSizeState) {
player.autoSizeRemove();
}
Object.defineProperty(player, 'pipEnabled', {
value: () => {
if (player.autoSizeState) {
player.autoSizeRemove();
}
if (!draggie) {
draggie = new Draggabilly($player, {
handle: '.artplayer-pip-header'
});
if (!draggie) {
draggie = new Draggabilly($player, {
handle: '.artplayer-pip-header',
});
append($pipTitle, option.title || i18n.get('Mini player'));
append($pipTitle, option.title || i18n.get('Mini player'));
proxy($pipClose, 'click', () => {
player.pipExit();
});
proxy($pipClose, 'click', () => {
player.pipExit();
});
destroyEvents.push(() => {
draggie.destroy();
});
} else {
setStyle($player, 'left', `${cachePos.x}px`);
setStyle($player, 'top', `${cachePos.y}px`);
}
destroyEvents.push(() => {
draggie.destroy();
});
} else {
setStyle($player, 'left', `${cachePos.x}px`);
setStyle($player, 'top', `${cachePos.y}px`);
}
$player.classList.add('artplayer-pip');
player.fullscreenExit();
player.fullscreenWebExit();
player.aspectRatioRemove();
player.playbackRateRemove();
art.emit('pipEnabled');
}
});
$player.classList.add('artplayer-pip');
player.fullscreenExit();
player.fullscreenWebExit();
player.aspectRatioRemove();
player.playbackRateRemove();
art.emit('pipEnabled');
},
});
Object.defineProperty(player, 'pipExit', {
value: () => {
if (player.pipState) {
$player.classList.remove('artplayer-pip');
cachePos = draggie.position;
setStyle($player, 'left', null);
setStyle($player, 'top', null);
player.fullscreenExit();
player.fullscreenWebExit();
player.aspectRatioRemove();
player.playbackRateRemove();
art.emit('pipExit');
}
}
});
Object.defineProperty(player, 'pipExit', {
value: () => {
if (player.pipState) {
$player.classList.remove('artplayer-pip');
cachePos = draggie.position;
setStyle($player, 'left', null);
setStyle($player, 'top', null);
player.fullscreenExit();
player.fullscreenWebExit();
player.aspectRatioRemove();
player.playbackRateRemove();
art.emit('pipExit');
}
},
});
Object.defineProperty(player, 'pipToggle', {
value: () => {
if (player.pipState) {
player.pipExit();
} else {
player.pipEnabled();
}
}
});
Object.defineProperty(player, 'pipToggle', {
value: () => {
if (player.pipState) {
player.pipExit();
} else {
player.pipEnabled();
}
},
});
}
export default function pipMix(art, player) {
if (document.pictureInPictureEnabled) {
nativePip(art, player);
} else {
customPip(art, player);
}
if (document.pictureInPictureEnabled) {
nativePip(art, player);
} else {
customPip(art, player);
}
}