Page MenuHomePhorge

No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None
diff --git a/src/components/audio_player/audio_player.js b/src/components/audio_player/audio_player.js
index 77fd685162..3da953df4e 100644
--- a/src/components/audio_player/audio_player.js
+++ b/src/components/audio_player/audio_player.js
@@ -1,74 +1,80 @@
import WaveSurfer from 'wavesurfer.js'
import rgb2hex from 'rgb2hex'
import Cursor from 'wavesurfer.js/dist/plugin/wavesurfer.cursor'
import Timeline from 'wavesurfer.js/dist/plugin/wavesurfer.timeline'
import { mapGetters } from 'vuex'
const AudioPlayer = {
props: [ 'src' ],
data () {
return {
waveSurfer: {},
- isPlaying: false
+ isPlaying: false,
+ isLoaded: false
}
},
mounted () {
const styles = getComputedStyle(this.$el)
const textColor = rgb2hex(styles.getPropertyValue('--text')).hex
this.waveSurfer = WaveSurfer.create({
container: this.$el.querySelector('.waveform'),
barGab: 1,
barWidth: 2,
barRadius: 2,
backend: 'MediaElement',
backgroundColor: rgb2hex(styles.getPropertyValue('--input')).hex,
progressColor: rgb2hex(styles.getPropertyValue('--link')).hex,
waveColor: rgb2hex(styles.getPropertyValue('--inputText')).hex,
cursorColor: rgb2hex(styles.getPropertyValue('--inputText')).hex,
plugins: [
Cursor.create({
showTime: true,
opacity: 1,
color: rgb2hex(styles.getPropertyValue('--link')).hex
}),
Timeline.create({
container: this.$el.querySelector('.timeline'),
notchPercentHeight: 50,
unlabeledNotchColor: textColor,
primaryColor: textColor,
secondaryColor: textColor,
primaryFontColor: textColor,
secondaryFontColor: textColor,
formatTimeCallback: (time) => {
let min = Math.floor(time / 60)
let sec = time - (min * 60)
if (sec < 10) {
sec = '0' + sec
}
return min + ':' + sec
}
})
]
})
this.waveSurfer.on('finish', () => {
this.isPlaying = false
})
- this.waveSurfer.load(this.src)
},
methods: {
handleMedia () {
if (this.isPlaying) {
this.waveSurfer.pause()
this.isPlaying = false
} else {
+ if (!this.isLoaded) {
+ this.waveSurfer.load(this.src)
+ }
this.waveSurfer.play()
this.isPlaying = true
}
}
},
computed: {
...mapGetters(['mergedConfig'])
+ },
+ beforeDestroy () {
+ this.waveSurfer.destroy()
}
}
export default AudioPlayer

File Metadata

Mime Type
text/x-diff
Expires
Sun, Aug 30, 3:10 AM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1737723
Default Alt Text
(2 KB)

Event Timeline