Skip to content

Commit

Permalink
支持内嵌音频
Browse files Browse the repository at this point in the history
  • Loading branch information
jooooock committed Sep 26, 2024
1 parent e7a1f76 commit f4ecaa7
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 1 deletion.
8 changes: 8 additions & 0 deletions public/custom-elements/mp-common-mpaudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,17 @@ class MpCommonMpaudio extends HTMLElement {
const audio = this.shadow.querySelector('audio')
audio.src = 'https://res.wx.qq.com/voice/getvoice?mediaid=' + this.fileid

audio.addEventListener('play', () => {
this.shadow.querySelector('#audio_progress_bar').style.display = 'block'
this.shadow.querySelector('.js_duration1').style.display = 'none'
this.shadow.querySelector('.js_duration2').style.display = 'block'
})
audio.addEventListener('ended', () => {
this.stopped = true
this.playing = false
this.shadow.querySelector('#audio_progress_bar').style.display = 'none'
this.shadow.querySelector('.js_duration1').style.display = 'block'
this.shadow.querySelector('.js_duration2').style.display = 'none'
})
audio.addEventListener('timeupdate', () => {
this.shadow.querySelector('.js_duration2 .start').textContent = formatTimeGap(Math.round(audio.currentTime))
Expand Down
114 changes: 113 additions & 1 deletion utils/index.ts

Large diffs are not rendered by default.

0 comments on commit f4ecaa7

Please sign in to comment.