mp:前端 message 增加视频播放的逻辑

This commit is contained in:
YunaiV 2023-01-08 20:18:51 +08:00
parent 9ec2f8b60f
commit 18bf098a1a
5 changed files with 8738 additions and 8139 deletions

View File

@ -65,6 +65,7 @@
"vue-cropper": "0.5.8",
"vue-meta": "^2.4.0",
"vue-router": "3.4.9",
"vue-video-player": "^5.0.2",
"vuedraggable": "2.24.3",
"vuex": "3.6.2",
"xml-js": "1.6.11"

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2021 JooLun
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,90 @@
<!--
- Copyright (C) 2018-2019
- All rights reserved, Designed By www.joolun.com
芋艿
bug 修复
1joolun 的做法使用 mediaId 从微信公众号下载对应的 mp4 素材从而播放内容
存在的问题mediaId 有效期是 3 超过时间后无法播放
2重构后的做法后端接收到微信公众号的视频消息后将视频消息的 media_id 的文件内容保存到文件服务器中这样前端可以直接使用 URL 播放
体验优化弹窗关闭后自动暂停视频的播放
-->
<template>
<div>
<!-- 提示 -->
<div @click="playVideo()">
<i class="el-icon-video-play" style="font-size: 40px!important;" ></i>
<p>点击播放视频</p>
</div>
<!-- 弹窗播放 -->
<el-dialog title="视频播放" :visible.sync="dialogVideo" width="40%" append-to-body @close="closeDialog">
<video-player v-if="playerOptions.sources[0].src" class="video-player vjs-custom-skin" ref="videoPlayer"
:playsinline="true" :options="playerOptions"
@play="onPlayerPlay($event)" @pause="onPlayerPause($event)">
</video-player>
</el-dialog>
</div>
</template>
<script>
// videoPlayer https://juejin.cn/post/6923056942281654285
import { videoPlayer } from 'vue-video-player'
require('video.js/dist/video-js.css')
require('vue-video-player/src/custom-theme.css')
export default {
name: "wxVideoPlayer",
props: {
url: { // https://www.iocoder.cn/xxx.mp4
type: String,
required: true
},
},
components: {
videoPlayer
},
data() {
return {
dialogVideo:false,
playerOptions: {
playbackRates: [0.5, 1.0, 1.5, 2.0], //
autoplay: false, // true,
muted: false, //
loop: false, //
preload: 'auto', // <video> auto ,
language: 'zh-CN',
aspectRatio: '16:9', // 使 - "16:9""4:3"
fluid: true, // trueVideo.js player
sources: [{
type: "video/mp4",
src: "" //
}],
poster: "", //
width: document.documentElement.clientWidth,
notSupportedMessage: '此视频暂无法播放,请稍后再试', // Video.js
controlBar: {
timeDivider: true,
durationDisplay: true,
remainingTimeDisplay: false,
fullscreenToggle: true //
}
}
}
},
methods: {
playVideo(){
this.dialogVideo = true
//
this.$set(this.playerOptions.sources[0], 'src', this.url)
},
closeDialog(){
//
this.$refs.videoPlayer.player.pause()
},
onPlayerPlay(player) {
},
onPlayerPause(player) {
},
}
};
</script>

View File

@ -46,7 +46,13 @@
</el-table-column>
<el-table-column label="消息类型" align="center" prop="type"/>
<el-table-column label="用户标识" align="center" prop="openid"/>
<el-table-column label="内容" align="center" prop="content"/>
<el-table-column label="内容" align="center" prop="content">
<template slot-scope="scope">
<div v-if="scope.row.type === 'video'">
<wx-video-player :url="scope.row.mediaUrl" style="margin-top: 10px" />
</div>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<!-- <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"-->
@ -112,11 +118,13 @@ import {
getMessagePage,
} from "@/api/mp/message";
import Editor from '@/components/Editor/index.vue';
import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue';
export default {
name: "WxFansMsg",
components: {
Editor,
WxVideoPlayer,
},
data() {
return {
@ -154,7 +162,10 @@ export default {
//
form: {},
//
rules: {}
rules: {},
//
accounts: []
};
},
created() {

File diff suppressed because it is too large Load Diff