|
@@ -1,6 +1,6 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div class="hello"> |
|
|
<div class="hello"> |
|
|
<div class="player"> |
|
|
|
|
|
|
|
|
<!-- <div class="player"> |
|
|
{{ currentAudioName || audioList[0].name }} |
|
|
{{ currentAudioName || audioList[0].name }} |
|
|
<audio-player |
|
|
<audio-player |
|
|
ref="audioPlayer" |
|
|
ref="audioPlayer" |
|
@@ -11,49 +11,78 @@ |
|
|
theme-color="#ff2929" |
|
|
theme-color="#ff2929" |
|
|
@playing="playing" |
|
|
@playing="playing" |
|
|
/> |
|
|
/> |
|
|
</div> |
|
|
|
|
|
|
|
|
</div> --> |
|
|
|
|
|
<div id="aplayer"></div> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
|
|
|
import "aplayer/dist/APlayer.min.css"; |
|
|
|
|
|
import APlayer from "aplayer"; |
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
wavesurfer: {}, |
|
|
|
|
|
currentAudioName: "", |
|
|
|
|
|
|
|
|
aplayer: null, |
|
|
|
|
|
aplayerSpeedNum: "1", //点击字体更换 |
|
|
|
|
|
arr: [], |
|
|
|
|
|
aplayerId: 0, |
|
|
|
|
|
aplayerLength: 0, |
|
|
audioList: [ |
|
|
audioList: [ |
|
|
{ |
|
|
{ |
|
|
name: "音频1", |
|
|
name: "音频1", |
|
|
url: "https://static.quhouse.com/audio/d7879fbcdfcc436189ce79e643e0aeb8.mp3", |
|
|
url: "https://static.quhouse.com/audio/d7879fbcdfcc436189ce79e643e0aeb8.mp3", |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
name: '音频2', |
|
|
|
|
|
url: 'https://static.quhouse.com/record/dev/2021-09-26/1632648911706-56129.mp3' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
name: "音频2", |
|
|
|
|
|
url: "https://static.quhouse.com/record/dev/2021-09-26/1632648911706-56129.mp3", |
|
|
|
|
|
}, |
|
|
], |
|
|
], |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
handleBeforePlay(next) { |
|
|
|
|
|
// 这里可以做一些事情... |
|
|
|
|
|
this.currentAudioName = |
|
|
|
|
|
this.audioList[this.$refs.audioPlayer.currentPlayIndex].name; |
|
|
|
|
|
console.log("我要开始播放了"); |
|
|
|
|
|
|
|
|
// handleBeforePlay(next) { |
|
|
|
|
|
// // 这里可以做一些事情... |
|
|
|
|
|
// this.currentAudioName = |
|
|
|
|
|
// this.audioList[this.$refs.audioPlayer.currentPlayIndex].name; |
|
|
|
|
|
// console.log("我要开始播放了"); |
|
|
|
|
|
|
|
|
next(); // 开始播放 |
|
|
|
|
|
}, |
|
|
|
|
|
playing(e) { |
|
|
|
|
|
console.log("我播放中", this.$refs.audioPlayer.currentTime); |
|
|
|
|
|
|
|
|
// next(); // 开始播放 |
|
|
|
|
|
// }, |
|
|
|
|
|
// playing(e) { |
|
|
|
|
|
// console.log("我播放中", this.$refs.audioPlayer.currentTime); |
|
|
|
|
|
// }, |
|
|
|
|
|
bofangchushihua() { |
|
|
|
|
|
var that = this; |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
this.aplayer = new APlayer({ |
|
|
|
|
|
container: document.getElementById("aplayer"), |
|
|
|
|
|
theme: "#2671E2", |
|
|
|
|
|
audio: [ |
|
|
|
|
|
{ |
|
|
|
|
|
url: "https://static.quhouse.com/audio/d7879fbcdfcc436189ce79e643e0aeb8.mp3", |
|
|
|
|
|
cover:"https://qufang.oss-cn-beijing.aliyuncs.com/recording/1626251359408.png", |
|
|
|
|
|
} |
|
|
|
|
|
], |
|
|
|
|
|
}); |
|
|
|
|
|
//结束的回调 |
|
|
|
|
|
this.aplayer.on("ended", function () { |
|
|
|
|
|
console.log("player ended"); |
|
|
|
|
|
}); |
|
|
|
|
|
this.aplayer.on("timeupdate", function () { |
|
|
|
|
|
// that.drawActive(that.aplayer.audio.currentTime * 1000); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
mounted() {}, |
|
|
|
|
|
|
|
|
mounted() { |
|
|
|
|
|
this.bofangchushihua(); |
|
|
|
|
|
}, |
|
|
}; |
|
|
}; |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<!-- Add "scoped" attribute to limit CSS to this component only --> |
|
|
<!-- Add "scoped" attribute to limit CSS to this component only --> |
|
|
<style scoped> |
|
|
<style scoped> |
|
|
|
|
|
|
|
|
.player{ |
|
|
|
|
|
|
|
|
.player { |
|
|
width: 30%; |
|
|
width: 30%; |
|
|
margin: 20px auto; |
|
|
margin: 20px auto; |
|
|
} |
|
|
} |
|
|