Files
ArtPlayer/packages/artplayer/src/player/playMix.js
T
2018-11-28 12:15:33 +08:00

28 lines
724 B
JavaScript

export default function playMix(art, player) {
const {
template: { $video },
i18n,
notice,
option: { mutex },
} = art;
Object.defineProperty(player, 'play', {
value: () => {
const promise = $video.play();
if (promise !== undefined) {
promise.then().catch(err => {
notice.show(err, true, 3000);
console.warn(err);
});
}
if (mutex) {
art.constructor.instances.filter(item => item !== art).forEach(item => item.player.pause());
}
notice.show(i18n.get('Play'));
art.emit('play');
},
});
}