import $ from 'jquery'; // 播放当前视频时停止其他视频播放 const stopOtherVideo = function () { $(document).ready(function () { let videos = $('video'); function pauseAll() { let self = this; ;[].forEach.call(videos, i => { // 将 videos 中其他的 video 全部暂停 i !== self && i.pause(); // i !== self && i.load(); }); }; // 给play事件绑定暂停函数 ;[].forEach.call(videos, i => { i.addEventListener('play', pauseAll.bind(i)) }); }); }; // 关闭所有视频 const closeAllVideoFun = function () { let videos = $('video'); let videosArr = Array.prototype.slice.call(videos); videosArr.forEach(x => { x.pause(); // x.load(); }); }; export { stopOtherVideo, closeAllVideoFun }