123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438 |
- <template>
- <view style="position: relative;">
- <view class="status_bar" :style="{height: statusBarHeight + 'px',width: windowWidth + 'px'}"></view>
- <view class="video-box" :style="{width: windowWidth + 'px'}">
- <video :style="{width: windowWidth + 'px',height: '422rpx'}" @tap="toggleBarChange" ref="myVideo2"
- id="myVideo2" :src="pickCatalog.videoUrl" :enable-progress-gesture="data.isFast==1"
- :enable-danmu="false" :danmu-btn="false" :initial-time="studyTimes" @play="onPlayVideo"
- @pause="onPauseVideo" :poster="poster" objectFit="contain" :show-progress="data.isFast==1"
- :title="pickCatalog.courseName" :controls="true" :show-fullscreen-btn="true"
- @controlstoggle="toggleBarChange" @timeupdate="onTimeUpdate" @fullscreenchange="onFullscreenChange"
- @waiting="onWaiting()" @ended="endedPlayNext()" @canplay="onVideoCanPlay"
- @canplaythrough="onVideoCanPlayThrough" @loadeddata="onLoadeddata" @loadedmetadata="onLoadedMetadata"
- @error="errorvideo">
- <!-- 疗法 -->
- <view
- v-if="showTherapy&&fullScreen"
- :class="fullScreen && direction == 'horizontal' ? 'horizontal':'horizontal'" @tap.stop>
- <view class="goods" @tap.stop="goToPro(showTherapyItem.packageId)">
- <image :src="showTherapyItem.imgUrl" mode="aspectFill" class="goodsimg"></image>
- <view class="goodsname"><text class="goodsname-txt">{{showTherapyItem.packageName}}</text>
- </view>
- </view>
- <view class="es-w-40 es-h-40" style="position: absolute;right:0rpx;top:0rpx;z-index:999">
- <image class="es-w-40 es-h-40" src="@/static/images/close40.png" @tap.stop="closeTherapy">
- </image>
- </view>
- </view>
- </video>
- <image class="back-img" @click="navBack" src="@/static/image/hall/back_white_icon.png"></image>
- </view>
-
- <view class="audiobox" v-if="showAudio" :style="{width: windowWidth + 'px',height: audioboxHeight + 'px'}" @click.stop>
- <view class="audiobox-title" :style="{width: windowWidth + 'px',paddingTop: paddingTop + 'px'}" @click="navBack">
- <uni-icons type="left" size="20" color="#fff"></uni-icons>
- <text class="textOne audiobox-text">{{pickCatalog.title}}</text>
- </view>
- <view class="es es-ver es-ac es-pc">
- <view class="es es-ac es-pc">
- <image class="es-icon-52 es-icon-play-last" src="/static/images/other/video/play-last.png" @click="audioBtnEvent('endedPlayPrev')"></image>
- <image class="es-icon-88 es-ml-50 es-mr-50"
- :src="audioPlayIng?'/static/images/other/video/play-stop.png':'/static/image/hall/video_icon.png'" @click="audioBtnEvent('playAudioAction')">
- </image>
- <image class="es-icon-52 es-icon-play-next" src="/static/images/other/video/play-next.png" @click="endedPlayNext('click')"></image>
- </view>
- <view class="audiobox-time audiobox-text">
- <text class="audiobox-text">{{playTime}} / {{formatSeconds(pickCatalog.seconds)}}</text>
- </view>
- </view>
- <view class="audiobox-video" :style="{width: windowWidth + 'px'}">
- <view class="audiobox-video-btn"><text class="audiobox-text" @click="audioBtnEvent('backPlayVideo')">返回视频</text></view>
- </view>
- </view>
-
- </view>
- </template>
- <script>
- import { formatSeconds } from '@/utils/tools.js'
- export default {
- data() {
- return {
- formatSeconds,
- showAudio: false,
- audioPlayIng: false,
- statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
- windowWidth: uni.getSystemInfoSync().windowWidth,
- audioboxHeight: 211,
- paddingTop: 15,
- videoContext: null,
- data: {
- isFast: false,
- },
- pickCatalog: {
- videoUrl: "https://tcpv.ylrzcloud.com/course/20241014/1728890026184.mp4",
- thumbnail: "",
- duration: 0,
- videoId: 0,
- seconds: 0,
- studyTime: null
- },
- studyTimes: 0,
- poster: "",
- fullScreen: false,
- direction: "",
- packageJsonList: [],
- showTherapy: false,
- showTherapyItem: {},
- currentTime: 0,
- nodeTime: 0,
- playTime:"00:00",
- }
- },
- onLoad() {
- this.paddingTop = this.statusBarHeight > 0 ? this.statusBarHeight : this.statusBarHeight + uni.upx2px(30)
- this.audioboxHeight = uni.upx2px(425) + this.statusBarHeight
- uni.$on('getPickCatalog', (data) => {
- this.pickCatalog = data
- this.packageJsonList = data.packageJson ? JSON.parse(data.packageJson) : []
- })
- uni.$on('getDataInfo', (data) => {
- this.data = data
- })
- uni.$on('studyTimes', (val) => {
- this.studyTimes = val
- })
- uni.$on('poster', (val) => {
- this.poster = val
- })
- uni.$on('playVideo', (val) => {
- this.videoContext.play();
- })
- uni.$on('pauseVideo', (val) => {
- this.videoContext.pause();
- })
- uni.$on('seekVideo', (val) => {
- this.videoContext.seek(val);
- })
- uni.$on('playTime', (val) => {
- this.playTime = val
- })
- uni.$on('changeData', (data) => {
- this.showAudio = data.showAudio
- this.audioPlayIng = data.audioPlayIng
- })
- },
- onReady() {
- this.videoContext = this.$refs.myVideo2
- },
- onUnload() {
- uni.$off('getPickCatalog')
- uni.$off('getDataInfo')
- uni.$off('studyTimes')
- uni.$off('poster')
- uni.$off('playVideo')
- uni.$off('pauseVideo')
- uni.$off('seekVideo')
- uni.$off('playTime')
- uni.$off('changeData')
- this.videoContext = null
- },
- methods: {
- navBack() {
- uni.$emit("navBack");
- },
- errorvideo(e) {
- console.log("播发错误", e)
- },
- toggleBarChange(event) {
- this.showFullScreenBtn = !this.showFullScreenBtn;
- },
- onPlayVideo() { //视频播放器事件
- uni.$emit("onPlayVideo");
- },
- onPauseVideo() {
- //this.isPlayIng=false;
- },
- onTimeUpdate(res) { //在视频播放时,检查缓存的变化,估算新增的已加载字节数并累加到 dataUsage 中。
- uni.$emit("onTimeUpdate", res);
- this.currentTime = Math.round(res.detail.currentTime)
- uni.$u.throttle(this.checkTherapy, 1000, true);
- },
- checkTherapy() {
- let node = this.packageJsonList.filter(item => item.duration == this.currentTime)
- if (node && node.length > 0) {
- this.nodeTime = node[0].duration
- this.showTherapyItem = node[0]
- if (!this.showTherapy) {
- this.showTherapy = true
- }
- } else {
- if (this.showTherapy && this.nodeTime && this.nodeTime > this.currentTime) {
- this.showTherapy = false
- }
- }
- },
- onFullscreenChange(event) {
- this.fullScreen = event.detail.fullScreen
- // direction取为 vertical 或 horizontal
- this.direction = event.detail.direction
- // 检查是否全屏
- if (!event.detail.fullScreen) {
- // 退出全屏,锁定竖屏
- plus.screen.lockOrientation('portrait-primary');
- }
- },
- onWaiting(res) {
- uni.$emit("onWaiting");
- //this.showToast("qxj onWaiting:"+JSON.stringify(res));
- },
- onProgress(event) {
- //console.log("qxj onProgress:"+JSON.stringify(event));
- //uni.showToast({title:event.detail.buffered,icon: 'none'});
- },
- endedPlayNext(type) {
- console.log('视频播放完成,开始下一个');
- uni.$emit("endedPlayNext",type);
- },
- onVideoCanPlay(res) {
- console.log('视频可以开始播放,但可能需要缓冲');
- //this.showToast("qxj onVideoCanPlay:"+JSON.stringify(res));
- },
- onVideoCanPlayThrough(res) {
- console.log('视频可以无暂停地播放');
- //this.showToast("qxj onVideoCanPlay:"+JSON.stringify(res));
- },
- onLoadeddata(res) {
- //this.showToast("qxj onLoadeddata res:"+JSON.stringify(res));
- console.log('视频缓冲完成');
- },
- onLoadedMetadata(event) { //在视频元数据加载完成时初始化。
- uni.$emit("onLoadedMetadata", event);
- },
- closeTherapy() {
- this.showTherapy = false
- },
- goToPro(productId) {
- this.videoContext.exitFullScreen()
- this.showTherapy = false
- setTimeout(() => {
- uni.navigateTo({
- url: "/pages/store/packageDetails?packageId=" + productId
- });
- }, 500);
- },
- audioBtnEvent(event) {
- uni.$emit("audioBtnEvent",event);
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .status_bar {
- background-color: #000;
- }
- .audiobox {
- // width: 100%;
- height: 422rpx;
- position: absolute;
- top: 0;
- left: 0;
- background-color: #333;
- z-index: 991;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- &-text {
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 26rpx;
- color: #fff;
- }
- &-video {
- position: absolute;
- bottom: 40rpx;
- left: 0;
- z-index: 992;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- }
- &-video-btn {
- background-color: rgba(255, 255, 255, 0.3);
- padding: 8rpx 20rpx;
- border-radius: 50rpx;
- }
- &-title {
- position: absolute;
- top: 0;
- left: 0;
- z-index: 992;
- padding: 30rpx 40rpx;
- // padding-top: calc(var(--status-bar-height) + 30rpx);
- width: 100%;
- box-sizing: border-box;
- background: linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.8) 100%);
- color: #ffff;
- display: flex;
- flex-direction: row;
- overflow: hidden;
- align-items: center;
- box-sizing: border-box;
- .textOne {
- flex: 1;
- overflow: hidden;
- verflow: hidden;
- word-break: break-all; /* break-all(允许在单词内换行 */
- text-overflow: ellipsis; /* 超出部分省略号 */
- -webkit-box-orient: vertical; /* 设置或检索伸缩盒对象的子元素的排列方式 */
- -webkit-line-clamp: 1; /* 显示的行数 */
- lines:1;
- }
- }
- &-time {
- margin-top: 18rpx;
- font-size: 24rpx;
- }
- }
- .video-box {
- height: 422rpx;
- overflow: hidden;
- position: relative;
- }
- .back-img {
- width: 50rpx;
- height: 50rpx;
- position: absolute;
- top: 20rpx;
- left: 34rpx;
- z-index: 999;
- }
- .horizontal {
- width: 130px;
- height: 150px;
- position: absolute;
- bottom: 50px;
- left: 20px;
- z-index: 999;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: flex-end;
- background-color: transparent;
- .es-w-40 {
- width: 20px;
- }
- .es-h-40 {
- height: 20px;
- }
- .goods {
- width: 120px;
- height: 140px;
- border-radius: 10px;
- background-color: rgba(255, 255, 255, 0.4);
- overflow: hidden;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
- .goodsimg {
- width: 100px;
- height: 100px;
- border-radius: 10px;
- }
- .goodsname {
- width: 100px;
- box-sizing: border-box;
- padding-top: 7px;
- verflow: hidden;
- word-break: break-all;
- /* break-all(允许在单词内换行 */
- text-overflow: ellipsis;
- /* 超出部分省略号 */
- -webkit-box-orient: vertical;
- /* 设置或检索伸缩盒对象的子元素的排列方式 */
- -webkit-line-clamp: 1;
- /* 显示的行数 */
- lines: 1;
- }
- .goodsname-txt {
- font-size: 12px;
- text-overflow: ellipsis;
- /* 超出部分省略号 */
- lines: 1;
- }
- }
- .therapybox {
- width: 290rpx;
- height: 350rpx;
- position: absolute;
- bottom: 100rpx;
- left: 40rpx;
- z-index: 999;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: flex-end;
- background-color: transparent;
- .goods {
- width: 270rpx;
- height: 330rpx;
- border-radius: 12rpx;
- background-color: rgba(255, 255, 255, 0.4);
- overflow: hidden;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
- .goodsimg {
- width: 240rpx;
- height: 240rpx;
- border-radius: 12rpx;
- }
- .goodsname {
- width: 240rpx;
- box-sizing: border-box;
- padding-top: 14rpx;
- verflow: hidden;
- word-break: break-all;
- /* break-all(允许在单词内换行 */
- text-overflow: ellipsis;
- /* 超出部分省略号 */
- -webkit-box-orient: vertical;
- /* 设置或检索伸缩盒对象的子元素的排列方式 */
- -webkit-line-clamp: 1;
- /* 显示的行数 */
- lines: 1;
- }
- .goodsname-txt {
- font-size: 26rpx;
- text-overflow: ellipsis;
- /* 超出部分省略号 */
- lines: 1;
- }
- }
- </style>
|