变更事件名称

This commit is contained in:
Harvey Zack committed 2018-11-21 14:13:37 +08:00
1 parent 4ecdb6b2d9
commit 16586d8d7e
26 files changed
+219 -152

No files matched your search

@@ -35,7 +35,7 @@ export default function aspectRatioMix(art, player) {
}
notice.show(`${i18n.get('Aspect ratio')}: ${ratioName}`);
art.emit('aspectRatio', ratio);
art.emit('aspectRatioChange', ratio);
}
});
@@ -46,6 +46,7 @@ export default function aspectRatioMix(art, player) {
setStyle($video, 'height', null);
setStyle($video, 'padding', null);
delete $player.dataset.aspectRatio;
art.emit('aspectRatioRemove');
}
}
});
@@ -55,6 +56,7 @@ export default function aspectRatioMix(art, player) {
const { aspectRatio } = $player.dataset;
if (aspectRatio) {
player.aspectRatio(aspectRatio.split(':'));
art.emit('aspectRatioReset');
}
}
});
@@ -23,6 +23,7 @@ export default function resizeMix(art, player) {
setStyle($player, 'width', '100%');
setStyle($player, 'height', `${percentage}%`);
}
art.emit('autoSizeChange');
}
});
@@ -31,6 +32,7 @@ export default function resizeMix(art, player) {
$container.classList.remove('artplayer-auto-size');
setStyle($player, 'width', null);
setStyle($player, 'height', null);
art.emit('autoSizeRemove');
}
});
}
+6 -4
View File
@@ -6,16 +6,18 @@ export default function flipMix(art, player) {
});
Object.defineProperty(player, 'flip', {
value: dir => {
const dirList = ['normal', 'horizontal', 'vertical'];
errorHandle(dirList.includes(dir), `The 'angle' need to be one of '[normal, horizontal, vertical]', but got ${dir}`);
art.refs.$player.dataset.flip = dir;
value: flip => {
const flipList = ['normal', 'horizontal', 'vertical'];
errorHandle(flipList.includes(flip), `The 'angle' need to be one of '[normal, horizontal, vertical]', but got ${flip}`);
art.refs.$player.dataset.flip = flip;
art.emit('flipChange', flip);
}
});
Object.defineProperty(player, 'flipRemove', {
value: () => {
delete art.refs.$player.dataset.flip;
art.emit('flipRemove');
}
});
}
+1 -1
View File
@@ -5,7 +5,7 @@ export default function pauseMin(art, player) {
value: () => {
$video.pause();
notice.show(i18n.get('Pause'));
art.emit('pause', $video);
art.emit('pause');
}
});
}
+2 -2
View File
@@ -44,7 +44,7 @@ export default function pipMix(art, player) {
player.fullscreenWebExit();
player.aspectRatioRemove();
player.playbackRateRemove();
art.emit('pip', true);
art.emit('pipEnabled');
}
});
@@ -59,7 +59,7 @@ export default function pipMix(art, player) {
player.fullscreenWebExit();
player.aspectRatioRemove();
player.playbackRateRemove();
art.emit('pip', false);
art.emit('pipExit');
}
}
});
+1 -1
View File
@@ -18,7 +18,7 @@ export default function playMix(art, player) {
}
notice.show(i18n.get('Play'));
art.emit('play', $video);
art.emit('play');
}
});
}
@@ -13,7 +13,7 @@ export default function playbackRateMix(art, player) {
$video.playbackRate = newRate;
$player.dataset.playbackRate = newRate;
notice.show(`${i18n.get('Rate')}: ${newRate === 1 ? i18n.get('Normal') : `${newRate}x`}`);
art.emit('playbackRate', newRate);
art.emit('playbackRateChange', newRate);
}
});
@@ -22,6 +22,7 @@ export default function playbackRateMix(art, player) {
if (player.$playbackRateState) {
player.playbackRate(1);
delete $player.dataset.playbackRate;
art.emit('playbackRateRemove');
}
}
});
@@ -31,6 +32,7 @@ export default function playbackRateMix(art, player) {
const { playbackRate } = $player.dataset;
if (playbackRate) {
player.playbackRate(Number(playbackRate));
art.emit('playbackRateReset');
}
}
});
@@ -1,10 +1,9 @@
import { setStyle, secondToTime } from '../utils';
export default function screenshotMix(art, player) {
const { option, notice } = art;
const { option, notice, refs: { $video } } = art;
function captureFrame() {
const { $video } = art.refs;
const canvas = document.createElement('canvas');
canvas.width = $video.videoWidth;
canvas.height = $video.videoHeight;
@@ -17,16 +16,21 @@ export default function screenshotMix(art, player) {
document.body.appendChild(elink);
elink.click();
document.body.removeChild(elink);
return dataUri;
}
Object.defineProperty(player, 'screenshot', {
value: () => {
const { crossOrigin } = $video;
try {
captureFrame();
art.emit('screenshot');
$video.crossOrigin = 'anonymous';
const dataUri = captureFrame();
art.emit('screenshot', dataUri);
} catch (error) {
notice.show(error);
console.warn(error);
} finally {
$video.crossOrigin = crossOrigin;
}
}
});
+1 -1
View File
@@ -12,7 +12,7 @@ export default function volumeMix(art, player) {
if ($video.volume !== 0) {
storage.set('volume', $video.volume);
}
art.emit('volume', $video.volume);
art.emit('volumeChange', $video.volume);
}
}
});