| | |
| | | :showPageList="loadPageList" |
| | | ></chapterOne> |
| | | </div> |
| | | <miniAudio :path="audioPath"></miniAudio> |
| | | <miniAudio |
| | | :path="audioPath" |
| | | :currentTime="currentTime" |
| | | ref="audioPlayer" |
| | | ></miniAudio> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | loadPageList: [], |
| | | questionData: {}, |
| | | renderSignMap: {}, |
| | | audioPath:'' |
| | | audioPath: "", |
| | | currentTime: null, |
| | | videoList: [], |
| | | }; |
| | | }, |
| | | computed: { |
| | |
| | | setTimeout(() => { |
| | | this.initSwiper(); |
| | | this.initViewer(); |
| | | this.getAduio(); |
| | | }, 200); |
| | | }, |
| | | }, |
| | |
| | | scrollFun(event) { |
| | | // 判断向上滚动还是向下滚动 |
| | | if (event.target.scrollTop > this.previousScrollTop) { |
| | | this.getAduio(); |
| | | // 向下 |
| | | const currentScrollTop = |
| | | event.target.scrollTop + event.target.offsetHeight; |
| | |
| | | } |
| | | } |
| | | } else if (event.target.scrollTop < this.previousScrollTop) { |
| | | this.handleAudio(); |
| | | // 向上 |
| | | const currentScrollTop = event.target.scrollTop; |
| | | if (currentScrollTop <= this.loadThreshold) { |
| | |
| | | } |
| | | // chooseWords |
| | | }, |
| | | // 获取auido实例 |
| | | // 页面向下滚动,音频小窗播放功能 |
| | | getAduio() { |
| | | let allVideo = ( |
| | | this.container ? this.container : document |
| | | ).querySelectorAll(".audio"); |
| | | allVideo = Array.from(allVideo) |
| | | allVideo = Array.from(allVideo); |
| | | this.videoList = allVideo; |
| | | if (allVideo.length) { |
| | | const playAudio = allVideo.reverse().find((item) => item.paused == false); |
| | | // 查找播放状态的最后一条音频 |
| | | const playAudio = allVideo |
| | | .reverse() |
| | | .find((item) => item.paused == false); |
| | | if (playAudio) { |
| | | console.log("第个音频在播放", playAudio.src); |
| | | this.audioPath = playAudio.src |
| | | const bottomGap = playAudio.getBoundingClientRect().bottom; |
| | | if (bottomGap < 0) { |
| | | playAudio.pause(); |
| | | this.audioPath = playAudio.src; |
| | | this.currentTime = playAudio.currentTime; |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | // 页面向上滚动,音频小窗回收 |
| | | handleAudio() { |
| | | if (!this.audioPath) return false; |
| | | let allVideo = ( |
| | | this.container ? this.container : document |
| | | ).querySelectorAll(".audio"); |
| | | allVideo = Array.from(allVideo); |
| | | if (allVideo.length) { |
| | | //查找与小窗播放音频同源的页面audio DOM |
| | | const playAudio = allVideo.find((item) => item.src == this.audioPath); |
| | | if (playAudio) { |
| | | const bottomGap = playAudio.getBoundingClientRect().bottom; |
| | | if (bottomGap >= 0) { |
| | | if (this.$refs.audioPlayer) { |
| | | const playerState = this.$refs.audioPlayer.getVideoPlayer(); |
| | | this.audioPath = ""; |
| | | playAudio.currentTime = playerState.currentTime; |
| | | if (!playerState.paused) playAudio.play(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |