|
@@ -19,15 +19,14 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- emits: ['loadedmetadata', 'loaded', 'togglePlay', 'ended', 'reset'],
|
|
|
+ emits: ['loadedmetadata', 'togglePlay', 'ended', 'reset'],
|
|
|
setup(props, { emit, expose }) {
|
|
|
const { item } = toRefs(props)
|
|
|
const videoRef = ref()
|
|
|
const videoItem = ref<Plyr>()
|
|
|
- const controlID = 'v' + Date.now() + Math.floor(Math.random() * 1000)
|
|
|
- const playBtnId = 'play' + Date.now() + Math.floor(Math.random() * 1000)
|
|
|
- const loopBtnId = 'loop' + Date.now() + Math.floor(Math.random() * 1000)
|
|
|
- const playIcon = 'icon' + Date.now() + Math.floor(Math.random() * 1000)
|
|
|
+ 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 toggleHideControl = (isShow: false) => {
|
|
|
videoItem.value?.toggleControls(isShow)
|
|
|
}
|
|
@@ -40,9 +39,9 @@ export default defineComponent({
|
|
|
if (!loopBtn || !videoItem.value) return
|
|
|
const isLoop = videoItem.value.loop
|
|
|
if (isLoop) {
|
|
|
- loopBtn.innerHTML = `<img src="${iconLoop}" />`
|
|
|
+ loopBtn.classList.remove(styles.active)
|
|
|
} else {
|
|
|
- loopBtn.innerHTML = `<img src="${iconLoopActive}" />`
|
|
|
+ loopBtn.classList.add(styles.active)
|
|
|
}
|
|
|
videoItem.value.loop = !videoItem.value.loop
|
|
|
}
|
|
@@ -59,9 +58,11 @@ export default defineComponent({
|
|
|
const playBtn = document.getElementById(playBtnId)
|
|
|
if (!playBtn) return
|
|
|
if (code == 'play') {
|
|
|
- playBtn.innerHTML = `<img class="${playIcon}" src="${iconplay}" />`
|
|
|
+ playBtn.classList.remove(styles.btnPause)
|
|
|
+ playBtn.classList.add(styles.btnPlay)
|
|
|
} else {
|
|
|
- playBtn.innerHTML = `<img class="${playIcon}" src="${iconpause}" />`
|
|
|
+ playBtn.classList.remove(styles.btnPlay)
|
|
|
+ playBtn.classList.add(styles.btnPause)
|
|
|
}
|
|
|
}
|
|
|
const controls = `
|
|
@@ -81,9 +82,12 @@ export default defineComponent({
|
|
|
<div class="${styles.actionWrap}">
|
|
|
<button id="${playBtnId}" class="${styles.actionBtn}">
|
|
|
<div class="van-loading van-loading--circular" aria-live="polite" aria-busy="true"><span class="van-loading__spinner van-loading__spinner--circular" style="color: rgb(255, 255, 255);"><svg class="van-loading__circular" viewBox="25 25 50 50"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span></div>
|
|
|
+ <img class="${styles.playIcon}" src="${iconplay}" />
|
|
|
+ <img class="${styles.playIcon}" src="${iconpause}" />
|
|
|
</button>
|
|
|
- <button id="${loopBtnId}" class="${styles.actionBtn}">
|
|
|
- <img src="${iconLoop}" />
|
|
|
+ <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>
|