|
@@ -70,17 +70,10 @@ export default defineComponent({
|
|
|
name: 'CoursewarePlay',
|
|
|
setup() {
|
|
|
const pageVisibility = usePageVisibility()
|
|
|
- const isPlay = ref(false)
|
|
|
/** 页面显示和隐藏 */
|
|
|
watch(pageVisibility, (value) => {
|
|
|
- const activeItem = data.itemList[popupData.activeIndex]
|
|
|
- if (activeItem.type != 'VIDEO') return
|
|
|
if (value == 'hidden') {
|
|
|
- isPlay.value = !activeItem.videoEle?.paused
|
|
|
- togglePlay(activeItem, false)
|
|
|
- } else {
|
|
|
- // 页面显示,并且
|
|
|
- if (isPlay.value) togglePlay(activeItem, true)
|
|
|
+ handleStop()
|
|
|
}
|
|
|
})
|
|
|
/** 设置播放容器 16:9 */
|
|
@@ -445,19 +438,16 @@ export default defineComponent({
|
|
|
|
|
|
/**停止所有的播放 */
|
|
|
const handleStop = () => {
|
|
|
- for (let i = 0; i < data.itemList.length; i++) {
|
|
|
- const activeItem = data.itemList[i]
|
|
|
-
|
|
|
- if (activeItem.type === 'VIDEO') {
|
|
|
- activeItem.videoEle?.pause()
|
|
|
- activeItem.videoEle?.stop()
|
|
|
- }
|
|
|
- // console.log('🚀 ~ activeItem:', activeItem)
|
|
|
- // 停止曲谱的播放
|
|
|
- if (activeItem.type === 'SONG') {
|
|
|
- activeItem.iframeRef?.contentWindow?.postMessage({ api: 'setPlayState' }, '*')
|
|
|
- }
|
|
|
+ const videos = document.querySelectorAll('video')
|
|
|
+ for (let i = 0; i < videos.length; i++) {
|
|
|
+ const videoEle = videos[i] as HTMLVideoElement
|
|
|
+ videoEle.pause()
|
|
|
}
|
|
|
+ data.itemList.forEach((item: any) => {
|
|
|
+ if (item.type === 'SONG') {
|
|
|
+ item.iframeRef?.contentWindow?.postMessage({ api: 'setPlayState' }, '*')
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
// 切换素材
|
|
|
const toggleMaterial = (itemActive: any) => {
|
|
@@ -592,40 +582,41 @@ export default defineComponent({
|
|
|
if (popupData.activeIndex == index) return
|
|
|
handleStop()
|
|
|
clearTimeout(acitveTimer.value)
|
|
|
- const oldIndex = popupData.activeIndex
|
|
|
checkedAnimation(popupData.activeIndex, index)
|
|
|
- popupData.activeIndex = index
|
|
|
-
|
|
|
- acitveTimer.value = setTimeout(
|
|
|
- () => {
|
|
|
- popupData.playIndex = index
|
|
|
- const item = data.itemList[index]
|
|
|
- if (item) {
|
|
|
- popupData.tabActive = item.knowledgePointId
|
|
|
- popupData.itemActive = item.id
|
|
|
- popupData.itemName = item.name
|
|
|
- popupData.tabName = item.tabName
|
|
|
- if (item.type == 'SONG') {
|
|
|
- activeData.model = true
|
|
|
+ nextTick(() => {
|
|
|
+ popupData.activeIndex = index
|
|
|
+
|
|
|
+ acitveTimer.value = setTimeout(
|
|
|
+ () => {
|
|
|
+ popupData.playIndex = index
|
|
|
+ const item = data.itemList[index]
|
|
|
+ if (item) {
|
|
|
+ popupData.tabActive = item.knowledgePointId
|
|
|
+ popupData.itemActive = item.id
|
|
|
+ popupData.itemName = item.name
|
|
|
+ popupData.tabName = item.tabName
|
|
|
+ if (item.type == 'SONG') {
|
|
|
+ activeData.model = true
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- requestAnimationFrame(() => {
|
|
|
- const _effectIndex = effectIndex.value + 1
|
|
|
- effectIndex.value = _effectIndex >= effects.length - 1 ? 0 : _effectIndex
|
|
|
+ requestAnimationFrame(() => {
|
|
|
+ const _effectIndex = effectIndex.value + 1
|
|
|
+ effectIndex.value = _effectIndex >= effects.length - 1 ? 0 : _effectIndex
|
|
|
|
|
|
- if (item && item.type === 'VIDEO') {
|
|
|
- // 自动播放下一个视频
|
|
|
- clearTimeout(activeData.timer)
|
|
|
- closeToast()
|
|
|
- item.autoPlay = true
|
|
|
- nextTick(() => {
|
|
|
- item.videoEle?.play()
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- activeData.isAnimation ? 800 : 0
|
|
|
- )
|
|
|
+ if (item && item.type === 'VIDEO') {
|
|
|
+ // 自动播放下一个视频
|
|
|
+ clearTimeout(activeData.timer)
|
|
|
+ closeToast()
|
|
|
+ item.autoPlay = true
|
|
|
+ nextTick(() => {
|
|
|
+ item.videoEle?.play()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ activeData.isAnimation ? 800 : 0
|
|
|
+ )
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const onChangeSwiper = useDebounceFn((type: string, itemActive?: any) => {
|
|
@@ -774,7 +765,7 @@ export default defineComponent({
|
|
|
}, 300)
|
|
|
}}
|
|
|
>
|
|
|
- {isRender && m.type === 'VIDEO' && (
|
|
|
+ {m.type === 'VIDEO' && (
|
|
|
<>
|
|
|
<VideoPlay
|
|
|
ref={(v: any) => (data.videoRefs[mIndex] = v)}
|
|
@@ -826,11 +817,6 @@ export default defineComponent({
|
|
|
}}
|
|
|
/>
|
|
|
)}
|
|
|
- {!isRender && (
|
|
|
- <div class={styles.loadWrap}>
|
|
|
- <Vue3Lottie animationData={playLoadData}></Vue3Lottie>
|
|
|
- </div>
|
|
|
- )}
|
|
|
</div>
|
|
|
) : (
|
|
|
''
|