本地发出的语音播放优化,必须从远端下载到本地之后再播放就好了,版本号升级,发布demo

This commit is contained in:
2022-02-22 17:20:51 +08:00
parent 5a52bdf2dd
commit 17e443fdeb
2 changed files with 63 additions and 58 deletions

View File

@@ -2,8 +2,8 @@
"name" : "ZH-HEALTH",
"appid" : "__UNI__C29473D",
"description" : "ZH-HEALTH您手上的健康管理专家",
"versionName" : "1.0.11",
"versionCode" : 111,
"versionName" : "1.0.13",
"versionCode" : 113,
"transformPx" : false,
/* 5+App */
"app-plus" : {

View File

@@ -2,9 +2,12 @@
<view class="">
<view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view>
<view class="msg--voice">
<view :class="['voice', isRemote ? 'left': 'right', {'onPlay': onPlay}]" :style="{width: width + 'rpx'}" @click="startPlay">
<image v-if="isRemote" class="icon" :class="{ 'videoFlicker' : onPlay && msgId == message.messageId }" src="@/static/icon/audio_green.png" mode="widthFix"></image>
<image v-else class="icon" :class="{ 'videoFlicker' : onPlay && msgId == message.messageId }" src="@/static/icon/audio_white.png" mode="widthFix"></image>
<view :class="['voice', isRemote ? 'left': 'right', {'onPlay': onPlay}]" :style="{width: width + 'rpx'}"
@click="startPlay">
<image v-if="isRemote" class="icon" :class="{ 'videoFlicker' : onPlay && msgId == message.messageId }"
src="@/static/icon/audio_green.png" mode="widthFix"></image>
<image v-else class="icon" :class="{ 'videoFlicker' : onPlay && msgId == message.messageId }"
src="@/static/icon/audio_white.png" mode="widthFix"></image>
<text class="duration">{{ duration }}"</text>
</view>
<u-badge isDot :show="message.content.local =='' && isRemote" />
@@ -33,7 +36,7 @@
return {
onPlay: false,
innerAC: null,
msgId : null
msgId: null
}
},
computed: {
@@ -77,8 +80,9 @@
this.stopPlay()
return
}
this.onPlay = true
// 如果下载到了本地,那么直接播放,否则调用下载语音消息接口,下载后再播放
if (this.message.content.local) {
if (this.message.content.local && this.message.content.local.indexOf('///data/user/') < 0) {
this.playVoice(this.message.content.local)
} else {
RongIMLib.downloadMediaMessage(this.message.messageId, {
@@ -104,11 +108,11 @@
this.innerAC.autoplay = false
this.msgId = this.message.messageId
this.innerAC.onCanplay(res => {
console.log('onCanplay')
this.innerAC.play()
})
this.innerAC.onPlay(res => {
this.onPlay = true
console.log('onPlay')
uni.$emit('onVoiceMessagePlay', this.message.messageId)
})
this.innerAC.onEnded(res => {
@@ -129,7 +133,6 @@
})
},
stopPlay() {
// 停止播放语音消息
if (this.innerAC) {
this.innerAC.stop()
}
@@ -139,19 +142,21 @@
</script>
<style>
@keyframes playFlicker{
0%{
@keyframes playFlicker {
0% {
opacity: 1;
}
50%{
50% {
opacity: .5;
}
100%{
100% {
opacity: 1;
}
}
.videoFlicker{
.videoFlicker {
animation: playFlicker 1s infinite;
}
</style>