|
@@ -3,10 +3,9 @@ import 'plyr/dist/plyr.css';
|
|
|
import Plyr from 'plyr';
|
|
|
import { ref } from 'vue';
|
|
|
import styles from './video.module.less';
|
|
|
-// import iconLoop from '../image/icon-loop.svg';
|
|
|
-// import iconLoopActive from '../image/icon-loop-active.svg';
|
|
|
import iconplay from '../image/icon-pause.svg';
|
|
|
import iconpause from '../image/icon-play.svg';
|
|
|
+import iconReplay from '../image/icon-replay.svg';
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'video-play',
|
|
@@ -29,7 +28,7 @@ export default defineComponent({
|
|
|
const videoItem = ref<Plyr>();
|
|
|
const controlID = 'v' + Date.now() + Math.floor(Math.random() * 100);
|
|
|
const playBtnId = 'play' + Date.now() + Math.floor(Math.random() * 100);
|
|
|
- const loopBtnId = 'loop' + Date.now() + Math.floor(Math.random() * 100);
|
|
|
+ const replayBtnId = 'replay' + Date.now() + Math.floor(Math.random() * 100);
|
|
|
const toggleHideControl = (isShow: false) => {
|
|
|
videoItem.value?.toggleControls(isShow);
|
|
|
};
|
|
@@ -37,16 +36,10 @@ export default defineComponent({
|
|
|
e.stopPropagation();
|
|
|
videoItem.value?.togglePlay();
|
|
|
};
|
|
|
- const toggleLoop = () => {
|
|
|
- const loopBtn = document.getElementById(loopBtnId);
|
|
|
- if (!loopBtn || !videoItem.value) return;
|
|
|
- const isLoop = videoItem.value.loop;
|
|
|
- if (isLoop) {
|
|
|
- loopBtn.classList.remove(styles.active);
|
|
|
- } else {
|
|
|
- loopBtn.classList.add(styles.active);
|
|
|
- }
|
|
|
- videoItem.value.loop = !videoItem.value.loop;
|
|
|
+ const toggleReplay = () => {
|
|
|
+ const replayBtn = document.getElementById(replayBtnId);
|
|
|
+ if (!replayBtn || !videoItem.value) return;
|
|
|
+ videoItem.value.restart();
|
|
|
};
|
|
|
const onDefault = () => {
|
|
|
document
|
|
@@ -56,7 +49,9 @@ export default defineComponent({
|
|
|
emit('reset');
|
|
|
});
|
|
|
document.getElementById(playBtnId)?.addEventListener('click', togglePlay);
|
|
|
- document.getElementById(loopBtnId)?.addEventListener('click', toggleLoop);
|
|
|
+ document
|
|
|
+ .getElementById(replayBtnId)
|
|
|
+ ?.addEventListener('click', toggleReplay);
|
|
|
};
|
|
|
|
|
|
const changePlayBtn = (code: string) => {
|
|
@@ -93,6 +88,11 @@ export default defineComponent({
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
+ <div class="${styles.actions}" style="padding-right: 0;">
|
|
|
+ <button id="${replayBtnId}" class="${styles.actionBtn} ${styles.loopBtn}">
|
|
|
+ <img class="loop" src="${iconReplay}" />
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
</div>`;
|
|
|
|
|
|
// <div class="${styles.actionWrap}">
|
|
@@ -101,10 +101,7 @@ export default defineComponent({
|
|
|
// <img class="${styles.playIcon}" src="${iconplay}" />
|
|
|
// <img class="${styles.playIcon}" src="${iconpause}" />
|
|
|
// </button>
|
|
|
- // <button id="${loopBtnId}" class="${styles.actionBtn} ${styles.loopBtn}">
|
|
|
- // <img class="loop" src="${iconLoop}" />
|
|
|
- // <img class="loopActive" src="${iconLoopActive}" />
|
|
|
- // </button>
|
|
|
+
|
|
|
// </div>
|
|
|
// <div>${item.value.name}</div>
|
|
|
|