!313 视频播放问题

Merge pull request !313 from 德仔/xzj
This commit is contained in:
德仔 2021-07-10 10:34:59 +00:00 committed by Gitee
commit 89cb00b71c
13 changed files with 318 additions and 5 deletions

View File

@ -9,7 +9,7 @@ stdiet:
# 实例演示开关
demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: /Users/wonder/Documents/Workspaces/java/ShengtangManage/running/uploadPath
profile: D:/ruoyi/uploadPath
# profile: D:/ruoyi/uploadPath
# 获取ip地址开关
addressEnabled: false
@ -19,7 +19,7 @@ stdiet:
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8090
port: 8091
servlet:
# 应用的访问路径
context-path: /

View File

@ -152,6 +152,27 @@ public class SysNutritionalVideoController extends BaseController
return AjaxResult.success(sysNutritionalVideos);
}
/**
* 获取营养视频播放凭证
*/
@PreAuthorize("@ss.hasPermi('custom:nutritionalVideo:query')")
@GetMapping(value = "/getVideoPlayAuth/{id}")
public AjaxResult getVideoPlayAuth(@PathVariable("id") Long id)
{
SysNutritionalVideo sysNutritionalVideos = sysNutritionalVideoService.selectSysNutritionalVideoById(id);
if(sysNutritionalVideos != null && StringUtils.isNotEmpty(sysNutritionalVideos.getVideoId())){
try{
String playAuth = AliyunVideoUtils.getVideoPlayAuth(sysNutritionalVideos.getVideoId());
sysNutritionalVideos.setPlayAuth(playAuth);
}catch (Exception e){
e.printStackTrace();
}
}
return AjaxResult.success(sysNutritionalVideos);
}
/**
* 根据视频videoId提交视频截图请求
*/

View File

@ -137,6 +137,29 @@ public class AliyunVideoUtils {
return client.createUploadVideo(createUploadVideoRequest);
}
/**
* 根据视频ID获取对应播放凭证
* @param videoId
* @return
* @throws Exception
*/
public static String getVideoPlayAuth(String videoId) throws Exception{
com.aliyun.vod20170321.Client client = AliyunVideoUtils.createClient();
GetVideoPlayAuthRequest getVideoPlayAuthRequest = new GetVideoPlayAuthRequest()
.setVideoId(videoId);
GetVideoPlayAuthResponse response = client.getVideoPlayAuth(getVideoPlayAuthRequest);
if(response != null){
GetVideoPlayAuthResponseBody body = response.body;
if(body != null && StringUtils.isNotEmpty(body.playAuth)){
return body.playAuth;
}
}
return null;
}
/**
*
* @param key

View File

@ -74,6 +74,9 @@ public class SysNutritionalVideo extends BaseEntity
private String playUrl;
//播放凭证
private String playAuth;
//文件名称
private String fileName;

View File

@ -146,6 +146,14 @@ public class SysWxUserLog extends BaseEntity
@Excel(name = "点评")
private String comment;
/** 点赞数量 */
@Excel(name = "点赞数量")
private Long thumbsupNum;
/** 健康宣言 */
@Excel(name = "健康宣言")
private String healthManifesto;
/** 删除标识 0未删除 1已删除 */
private Long delFlag;

View File

@ -0,0 +1,65 @@
package com.stdiet.custom.dto.response;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 打卡社区
*/
@Data
public class CommunityPunchReponse {
/**
* 微信openid
*/
private String openid;
/**
* 客户ID
*/
private Long cusId;
/**
* 昵称
*/
private String nickName;
/**
* 头像
*/
private String avatarUrl;
/**
* 打卡日期时间
*/
private Date logTime;
/**
* 当天打卡体重
*/
private BigDecimal weight;
/**
* 营养师评论
*/
private String comment;
/**
* 点赞数
*/
private String thumbsupNum;
/**
* 健康宣言
*/
private String healthManifesto;
/**
* 近期打卡体重信息 logTime: 打卡日期 weight: 体重
*/
private List<Map<String,Object>> recentWeight;
}

View File

@ -38,6 +38,8 @@
<result property="targetWeight" column="target_weight" />
<result property="executionScore" column="execution_score" />
<result property="comment" column="comment" />
<result property="thumbsupNum" column="thumbsup_num" />
<result property="healthManifesto" column="health_manifesto" />
<result property="delFlag" column="del_flag" />
<!-- 非持久字段 -->
<result property="customerName" column="customer_name"></result>
@ -71,6 +73,8 @@
<result property="targetWeight" column="target_weight" />
<result property="executionScore" column="execution_score" />
<result property="comment" column="comment" />
<result property="thumbsupNum" column="thumbsup_num" />
<result property="healthManifesto" column="health_manifesto" />
</resultMap>
<sql id="selectSysWxUserLogVo">
@ -168,6 +172,8 @@
<if test="targetWeight != null">target_weight,</if>
<if test="executionScore != null">execution_score,</if>
<if test="comment != null">comment,</if>
<if test="thumbsupNum != null">thumbsup_num,</if>
<if test="healthManifesto != null">health_manifesto,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -202,6 +208,8 @@
<if test="targetWeight != null">target_weight = #{targetWeight},</if>
<if test="executionScore != null">execution_score = #{executionScore},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="thumbsupNum != null">#{thumbsupNum},</if>
<if test="healthManifesto != null">#{healthManifesto},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
</insert>
@ -240,6 +248,8 @@
<if test="targetWeight != null">target_weight = #{targetWeight},</if>
<if test="executionScore != null">execution_score = #{executionScore},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="thumbsupNum != null">thumbsup_num = #{thumbsupNum},</if>
<if test="healthManifesto != null">health_manifesto = #{healthManifesto},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
@ -307,4 +317,18 @@
order by wxlog.log_time desc
</select>
<!-- 查询打卡社区内容 -->
<!--<select id="">
select wxinfo.openid,wxinfo.cus_id,wxinfo.nick_name,wxinfo.avatar_url,wxlog.log_time,wxlog.weight,wxlog.comment,wxlog.thumbsup_num,wxlog.health_manifesto from sys_wx_user_log wxlog
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
where wxlog.del_flag = 0
<if test="logTime">
and wxlog.log_time >= #{logTime}
</if>
order by wxlog.log_time desc
</select>-->
</mapper>

View File

@ -13,10 +13,13 @@
rel="stylesheet"
href="//at.alicdn.com/t/font_2343184_w0runuauamq.css"
/>
<link rel="stylesheet" href="https://g.alicdn.com/de/prismplayer/2.9.6/skins/default/aliplayer-min.css" />
<script src="../lib/aliyunVideo/es6-promise.min.js"></script>
<script src="../lib/aliyunVideo/aliyun-oss-sdk-6.13.0.min.js"></script>
<script src="../lib/aliyunVideo/aliyun-upload-sdk-1.5.2.min.js"></script>
<script src="https://g.alicdn.com/de/prismplayer/2.9.6/aliplayer-min.js"></script>
<title><%= webpackConfig.name %></title>
<style>
html,

View File

@ -96,5 +96,14 @@ export function getVideoSnapshot(id) {
})
}
// 查询营养视频播放凭证
export function getVideoPlayAuth(id) {
return request({
url: '/custom/nutritionalVideo/getVideoPlayAuth/' + id,
method: 'get'
})
}

View File

@ -275,14 +275,14 @@
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8">
<!--<el-col :span="8">
<el-form-item label="食谱是否连续" prop="recipesPlanContinue">
<el-select v-model="form.recipesPlanContinue" placeholder="请选择食谱连续状态">
<el-option label="是" :value="parseInt('1')"></el-option>
<el-option label="否" :value="parseInt('0')"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-col>-->
<el-col :span="10">
<el-form-item label="服务开始时间" prop="startTime" label-width="180">
<el-date-picker

View File

@ -0,0 +1,63 @@
<template>
<el-dialog
:title="title"
:visible.sync="visible"
width="680px"
append-to-body
:close-on-click-modal="false"
>
<VideoTemplate v-if="visible" :videoId="video.videoId" :playAuth="video.playAuth" ></VideoTemplate>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</template>
<script>
import VideoTemplate from "@/components/VideoPlay/video";
export default {
name: "VideoPlay",
props: {
},
data() {
return {
title: "",
visible:false,
player: null,
video: null
}
},
created() {
},
computed: {
},
components:{
VideoTemplate
},
methods: {
showDialog(video) {
this.player = null;
this.video = video;
this.title = this.video.title;
this.visible = true;
/*let self = this;
let t = setTimeout(function(){
self.createPlayer();
},500);*/
},
//
cancel() {
this.visible = false;
// this.reset();
},
},
watch: {
}
};
</script>

View File

@ -0,0 +1,78 @@
<template>
<div>
<div class="prism-player" id="J_prismPlayer" :style="'height:'+height+'px;width:'+width+'px'"></div>
</div>
</template>
<script>
export default {
name: "video",
props: {
videoId: {
type: String,
default: ''
},
playAuth: {
type: String,
default: ''
},
width:{
type: Number,
default: 630
},
height:{
type: Number,
default: 350
}
},
data() {
return{
player: null
}
},
created() {
},
mounted(){
this.$nextTick(function(){
this.createPlayer();
});
},
computed: {
},
methods: {
createPlayer(){
this.player = new Aliplayer({
/*id: 'J_prismPlayer',
width: '100%',
autoplay: false,
//,
source : this.video.playUrl*/
"id": "J_prismPlayer",
"vid": this.videoId,
"playauth": this.playAuth,
"qualitySort": "asc",
"format": "mp4",
"mediaType": "video",
"width": "100%",
"height": "500px",
"autoplay": false,
"isLive": false,
"rePlay": false,
"playsinline": true,
"preload": true,
"controlBarVisibility": "hover",
"useH5Prism": true
},function(){
})
}
},
watch: {
}
};
</script>

View File

@ -208,7 +208,7 @@
size="mini"
type="text"
icon="el-icon-edit"
@click="getVideoPlayUrl(scope.row.id)"
@click="showVideoPlay(scope.row)"
v-hasPermi="['custom:nutritionalVideo:query']"
>播放</el-button
>
@ -360,6 +360,9 @@
<!-- 手动选择封面 -->
<VideoSelectCover ref="videoSelectCoverRef"></VideoSelectCover>
<!-- 视频播放 -->
<VideoPlay ref="videoPlayRef"></VideoPlay>
</div>
</template>
@ -373,6 +376,7 @@ import {
exportNutritionalVideo,
updateWxShow,
getVideoPlayUrlById,
getVideoPlayAuth
} from "@/api/custom/nutritionalVideo";
import { getAllClassify } from "@/api/custom/videoClassify";
import UploadVideo from "@/components/UploadVideo";
@ -383,6 +387,7 @@ import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import IconSelect from "@/components/IconSelect";
import VideoSelectCover from "@/components/VideoSelectCover";
import VideoPlay from "@/components/VideoPlay";
export default {
name: "NutritionalVideo",
data() {
@ -452,6 +457,7 @@ export default {
Treeselect,
IconSelect,
VideoSelectCover,
VideoPlay
},
methods: {
/** 查询营养视频列表 */
@ -649,6 +655,16 @@ export default {
})
.catch(function () {});
},
showVideoPlay(row){
getVideoPlayAuth(row.id).then((response) => {
row.playAuth = response.data.playAuth;;
if (row.playAuth != undefined && row.playAuth != null) {
this.$refs.videoPlayRef.showDialog(row);
}else{
this.msgError("视频资源不存在");
}
});
}
},
};
</script>