本地发出的语音播放优化,必须从远端下载到本地之后再播放就好了,版本号升级,发布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", "name" : "ZH-HEALTH",
"appid" : "__UNI__C29473D", "appid" : "__UNI__C29473D",
"description" : "ZH-HEALTH您手上的健康管理专家", "description" : "ZH-HEALTH您手上的健康管理专家",
"versionName" : "1.0.11", "versionName" : "1.0.13",
"versionCode" : 111, "versionCode" : 113,
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus" : {

View File

@@ -2,9 +2,12 @@
<view class=""> <view class="">
<view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view> <view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view>
<view class="msg--voice"> <view class="msg--voice">
<view :class="['voice', isRemote ? 'left': 'right', {'onPlay': onPlay}]" :style="{width: width + 'rpx'}" @click="startPlay"> <view :class="['voice', isRemote ? 'left': 'right', {'onPlay': onPlay}]" :style="{width: width + 'rpx'}"
<image v-if="isRemote" class="icon" :class="{ 'videoFlicker' : onPlay && msgId == message.messageId }" src="@/static/icon/audio_green.png" mode="widthFix"></image> @click="startPlay">
<image v-else class="icon" :class="{ 'videoFlicker' : onPlay && msgId == message.messageId }" src="@/static/icon/audio_white.png" mode="widthFix"></image> <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> <text class="duration">{{ duration }}"</text>
</view> </view>
<u-badge isDot :show="message.content.local =='' && isRemote" /> <u-badge isDot :show="message.content.local =='' && isRemote" />
@@ -77,8 +80,9 @@
this.stopPlay() this.stopPlay()
return 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) this.playVoice(this.message.content.local)
} else { } else {
RongIMLib.downloadMediaMessage(this.message.messageId, { RongIMLib.downloadMediaMessage(this.message.messageId, {
@@ -104,11 +108,11 @@
this.innerAC.autoplay = false this.innerAC.autoplay = false
this.msgId = this.message.messageId this.msgId = this.message.messageId
this.innerAC.onCanplay(res => { this.innerAC.onCanplay(res => {
console.log('onCanplay')
this.innerAC.play() this.innerAC.play()
}) })
this.innerAC.onPlay(res => { this.innerAC.onPlay(res => {
this.onPlay = true console.log('onPlay')
uni.$emit('onVoiceMessagePlay', this.message.messageId) uni.$emit('onVoiceMessagePlay', this.message.messageId)
}) })
this.innerAC.onEnded(res => { this.innerAC.onEnded(res => {
@@ -129,7 +133,6 @@
}) })
}, },
stopPlay() { stopPlay() {
// 停止播放语音消息
if (this.innerAC) { if (this.innerAC) {
this.innerAC.stop() this.innerAC.stop()
} }
@@ -143,9 +146,11 @@
0% { 0% {
opacity: 1; opacity: 1;
} }
50% { 50% {
opacity: .5; opacity: .5;
} }
100% { 100% {
opacity: 1; opacity: 1;
} }