播放器
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="richDetail">
|
<view class="richDetail">
|
||||||
<!-- 公共组件-每个页面必须引入 -->
|
<!-- 公共组件-每个页面必须引入 -->
|
||||||
|
|
||||||
<view
|
<view
|
||||||
scroll-x="true"
|
scroll-x="true"
|
||||||
class="detail_title video_box"
|
class="detail_title video_box"
|
||||||
@@ -28,7 +27,7 @@
|
|||||||
import $http from "@/config/requestConfig.js";
|
import $http from "@/config/requestConfig.js";
|
||||||
import { mapState } from "vuex";
|
import { mapState } from "vuex";
|
||||||
export default {
|
export default {
|
||||||
props: ["detailInfo", "dataList", "currentVideo"],
|
props: ["detailInfo", "dataList", "currentVideo", "changeVideoLock"],
|
||||||
components: {},
|
components: {},
|
||||||
data() {
|
data() {
|
||||||
return {};
|
return {};
|
||||||
@@ -50,6 +49,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleClick(data) {
|
handleClick(data) {
|
||||||
|
if(this.changeVideoLock){
|
||||||
|
return
|
||||||
|
}
|
||||||
console.log("data at line 35:", data);
|
console.log("data at line 35:", data);
|
||||||
this.$emit("open", data);
|
this.$emit("open", data);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -52,6 +52,9 @@
|
|||||||
<div @tap="renderScript.emitReplayVideoFlagFalse" ref="videoContent8" v-show="false" class="videoContent8">
|
<div @tap="renderScript.emitReplayVideoFlagFalse" ref="videoContent8" v-show="false" class="videoContent8">
|
||||||
隐藏播放下一条界面
|
隐藏播放下一条界面
|
||||||
</div>
|
</div>
|
||||||
|
<div @tap="renderScript.emitUnlockChangeVideo" ref="videoContent9" v-show="false" class="videoContent9">
|
||||||
|
释放切换键锁
|
||||||
|
</div>
|
||||||
<div class="fullScreenButton-container">
|
<div class="fullScreenButton-container">
|
||||||
<div :class="`prism-fullscreen-btn ${isFullScreen ? 'fullscreen' : ''}`"
|
<div :class="`prism-fullscreen-btn ${isFullScreen ? 'fullscreen' : ''}`"
|
||||||
@tap="renderScript.changeVideoScreen"></div>
|
@tap="renderScript.changeVideoScreen"></div>
|
||||||
@@ -151,6 +154,9 @@
|
|||||||
console.log('复原replayVideoFlag',this.replayVideoFlag);
|
console.log('复原replayVideoFlag',this.replayVideoFlag);
|
||||||
this.replayVideoFlag = false
|
this.replayVideoFlag = false
|
||||||
},
|
},
|
||||||
|
UnlockChangeVideo(){
|
||||||
|
this.$emit('unlockChangeVideo')
|
||||||
|
},
|
||||||
hideNextVideo(){
|
hideNextVideo(){
|
||||||
this.showCountDown = false
|
this.showCountDown = false
|
||||||
this.playEndBlank = false
|
this.playEndBlank = false
|
||||||
@@ -439,13 +445,12 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script module="renderScript" lang="renderjs">
|
<script module="renderScript" lang="renderjs">
|
||||||
var GolbalPlayerOptions = {}
|
|
||||||
var videoData = null
|
var videoData = null
|
||||||
var _seconds = 0
|
var _seconds = 0
|
||||||
var ReplayVideoFlag = false
|
var ReplayVideoFlag = false
|
||||||
var curStatus = null
|
var curStatus = null
|
||||||
var diff = 0
|
var diff = 0
|
||||||
var myplayer = undefined
|
var myplayer = undefined
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -455,7 +460,6 @@
|
|||||||
// 在适合的生命周期,通过script和link标签引入播放器sdk、css
|
// 在适合的生命周期,通过script和link标签引入播放器sdk、css
|
||||||
console.log(this.options, '这是monted')
|
console.log(this.options, '这是monted')
|
||||||
this.loadWebPlayerSDK()
|
this.loadWebPlayerSDK()
|
||||||
this.loadComponent()
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -503,6 +507,9 @@
|
|||||||
emitReplayVideoFlagFalse(event, ownerInstance) {
|
emitReplayVideoFlagFalse(event, ownerInstance) {
|
||||||
ownerInstance.callMethod('replayVideoFlagFalse')
|
ownerInstance.callMethod('replayVideoFlagFalse')
|
||||||
},
|
},
|
||||||
|
emitUnlockChangeVideo(event, ownerInstance) {
|
||||||
|
ownerInstance.callMethod('UnlockChangeVideo')
|
||||||
|
},
|
||||||
async receiveFirstTime(newValue, oldValue, ownerVm, vm) {
|
async receiveFirstTime(newValue, oldValue, ownerVm, vm) {
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -568,11 +575,16 @@
|
|||||||
},
|
},
|
||||||
// renderjs阿里云播放器引入与配置
|
// renderjs阿里云播放器引入与配置
|
||||||
getLive() {
|
getLive() {
|
||||||
// console.log('这是这只只是666666:', this.firstTime, this.videoData)
|
console.log('这是这只只是666666:', this.firstTime, this.videoData)
|
||||||
if (myplayer) {
|
if (this.player) {
|
||||||
|
this.player.pause();
|
||||||
|
myplayer.pause()
|
||||||
this.player.dispose();
|
this.player.dispose();
|
||||||
$('#url-player-test').empty();
|
$('#url-player-test').empty();
|
||||||
this.player = null;
|
this.player = null;
|
||||||
|
myplayer = null
|
||||||
|
|
||||||
|
console.log('上一条视频的状态,',this.player.getStatus());
|
||||||
}
|
}
|
||||||
var fullScreenButtonComponent = Aliplayer.Component({
|
var fullScreenButtonComponent = Aliplayer.Component({
|
||||||
/**
|
/**
|
||||||
@@ -697,7 +709,7 @@
|
|||||||
align: "blabs",
|
align: "blabs",
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 44
|
y: 44
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "playButton",
|
name: "playButton",
|
||||||
align: "tl",
|
align: "tl",
|
||||||
@@ -716,7 +728,6 @@
|
|||||||
x: 15,
|
x: 15,
|
||||||
y: 12
|
y: 12
|
||||||
},
|
},
|
||||||
// {name: "fullScreenButton", align: "tr", x: 10, y: 12},
|
|
||||||
{
|
{
|
||||||
name: "volume",
|
name: "volume",
|
||||||
align: "tr",
|
align: "tr",
|
||||||
@@ -764,17 +775,17 @@
|
|||||||
}
|
}
|
||||||
console.log('这是没有加密的视频');
|
console.log('这是没有加密的视频');
|
||||||
}
|
}
|
||||||
// GolbalPlayerOptions = playerOptions
|
|
||||||
var player = new Aliplayer(playerOptions, function(player) {});
|
var player = new Aliplayer(playerOptions, function(player) {});
|
||||||
this.player = player;
|
this.player = player;
|
||||||
myplayer = player;
|
myplayer = player;
|
||||||
|
// console.log('myplayer------------',myplayer.loadByUrl('https://www.w3schools.com/html/movie.mp4'));
|
||||||
console.log('myplayer------------',JSON.stringify(myplayer));
|
|
||||||
console.log('是否拿到第一次初始值呢', this.platform, typeof this.firstTime, this.firstTime)
|
console.log('是否拿到第一次初始值呢', this.platform, typeof this.firstTime, this.firstTime)
|
||||||
|
|
||||||
player.on('ready', function() {
|
player.on('ready', function() {
|
||||||
console.log('播放器准备就绪,开始播放');
|
console.log('播放器准备就绪,开始播放');
|
||||||
player.play()
|
player.play()
|
||||||
|
$('.videoContent9').click()
|
||||||
})
|
})
|
||||||
player.on('play', function() {
|
player.on('play', function() {
|
||||||
console.log('开始播放------');
|
console.log('开始播放------');
|
||||||
@@ -823,7 +834,10 @@
|
|||||||
$('.videoContent2').click()
|
$('.videoContent2').click()
|
||||||
$('.videoContent6').click()
|
$('.videoContent6').click()
|
||||||
})
|
})
|
||||||
|
this.player.on('pause', function() {
|
||||||
|
console.log('触发暂停')
|
||||||
|
this.player.pause(true)
|
||||||
|
})
|
||||||
this.player.on('error', function() {
|
this.player.on('error', function() {
|
||||||
console.log('播放出错')
|
console.log('播放出错')
|
||||||
$('.videoContent5').click()
|
$('.videoContent5').click()
|
||||||
@@ -880,10 +894,10 @@
|
|||||||
},
|
},
|
||||||
// 监听视频参数变化,并赋值给常量
|
// 监听视频参数变化,并赋值给常量
|
||||||
receiveMsg(newValue, oldValue, ownerVm, vm) {
|
receiveMsg(newValue, oldValue, ownerVm, vm) {
|
||||||
|
|
||||||
//数据变化
|
//数据变化
|
||||||
videoData = newValue
|
videoData = newValue
|
||||||
if (videoData) {
|
if (videoData) {
|
||||||
|
return
|
||||||
console.log('切换后的播放数据videoData',videoData.type);
|
console.log('切换后的播放数据videoData',videoData.type);
|
||||||
if (videoData.type == 1) {
|
if (videoData.type == 1) {
|
||||||
if (videoData.m3u8Url != '' && videoData.m3u8Url != null) {
|
if (videoData.m3u8Url != '' && videoData.m3u8Url != null) {
|
||||||
@@ -947,25 +961,12 @@
|
|||||||
document.body.appendChild(l_tag);
|
document.body.appendChild(l_tag);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
loadComponent() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const s_tag = document.createElement('script');
|
|
||||||
s_tag.type = 'text/javascript';
|
|
||||||
// 需要先下载组件 js 文件,放到项目 /static/ 目录下
|
|
||||||
// 下载地址:https://github.com/aliyunvideo/AliyunPlayer_Web/blob/master/customComponents/dist/aliplayer-components/aliplayercomponents-1.0.9.min.js
|
|
||||||
s_tag.src = '@/static/aliplayercomponents-1.0.9.min.js';
|
|
||||||
s_tag.charset = 'utf-8';
|
|
||||||
s_tag.onload = () => {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
document.body.appendChild(s_tag);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.cancelNext{display: inline-block;
|
.cancelNext{display: inline-block; margin-right: 20rpx;
|
||||||
border-radius: 10rpx; margin-top: 10rpx;
|
border-radius: 10rpx; margin-top: 10rpx;
|
||||||
padding: 10rpx 20rpx !important; background-color: #fff !important;
|
padding: 10rpx 20rpx !important; background-color: #fff !important;
|
||||||
color: #000; text-align: center; line-height: 50rpx;}
|
color: #000; text-align: center; line-height: 50rpx;}
|
||||||
@@ -973,7 +974,7 @@
|
|||||||
.nextText{}
|
.nextText{}
|
||||||
.showCountDownd {
|
.showCountDownd {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
height: 100%; width: 90%; background-color: rgba(0, 0, 0, 0.6);
|
height: 100%; width: 100%; background-color: rgba(0, 0, 0, 0.6);
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
@changeScreenLoading="changeScreenLoading"
|
@changeScreenLoading="changeScreenLoading"
|
||||||
@hideNextVideo="hideNextVideo"
|
@hideNextVideo="hideNextVideo"
|
||||||
@startNextVideoCountDown = "startNextVideoCountDown"
|
@startNextVideoCountDown = "startNextVideoCountDown"
|
||||||
|
@unlockChangeVideo="unlockChangeVideo"
|
||||||
v-if="isfresh"
|
v-if="isfresh"
|
||||||
ref="commonVideo"
|
ref="commonVideo"
|
||||||
:secondCountDown="secondCountDown"
|
:secondCountDown="secondCountDown"
|
||||||
@@ -55,6 +56,7 @@
|
|||||||
:currentVideo="currentVideo"
|
:currentVideo="currentVideo"
|
||||||
:dataList="videoArray"
|
:dataList="videoArray"
|
||||||
@open="changeVideo"
|
@open="changeVideo"
|
||||||
|
:changeVideoLock="changeVideoLock"
|
||||||
>
|
>
|
||||||
</common-curriculum-video>
|
</common-curriculum-video>
|
||||||
</view>
|
</view>
|
||||||
@@ -117,6 +119,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
changeVideoLock:false, // 切换键锁
|
||||||
isFullScreen: false,
|
isFullScreen: false,
|
||||||
screenLoading: false,
|
screenLoading: false,
|
||||||
isfresh: false,
|
isfresh: false,
|
||||||
@@ -228,6 +231,9 @@ export default {
|
|||||||
...mapState(["userInfo"]),
|
...mapState(["userInfo"]),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
unlockChangeVideo(){
|
||||||
|
this.changeVideoLock = false
|
||||||
|
},
|
||||||
startNextVideoCountDown(){
|
startNextVideoCountDown(){
|
||||||
this.secondCountDown = 10
|
this.secondCountDown = 10
|
||||||
let that = this
|
let that = this
|
||||||
@@ -288,6 +294,7 @@ export default {
|
|||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
},
|
},
|
||||||
initVideo() {
|
initVideo() {
|
||||||
|
this.changeVideoLock = true
|
||||||
this.screenLoading = false;
|
this.screenLoading = false;
|
||||||
this.isfresh = false;
|
this.isfresh = false;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
@@ -301,6 +308,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
changeVideo(data) {
|
changeVideo(data) {
|
||||||
|
this.changeVideoLock = true
|
||||||
if(this.countDownTimer){
|
if(this.countDownTimer){
|
||||||
this.hideNextVideo()
|
this.hideNextVideo()
|
||||||
}
|
}
|
||||||
@@ -315,10 +323,9 @@ export default {
|
|||||||
// this.$refs.commonVideo.handleEnd();
|
// this.$refs.commonVideo.handleEnd();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
||||||
this.$refs.commonVideo.changeVideo(data);
|
// this.$refs.commonVideo.changeVideo(data);
|
||||||
this.currentVideo = data;
|
this.currentVideo = data;
|
||||||
// this.changeVideo()
|
this.initVideo();
|
||||||
// this.initVideo();
|
|
||||||
this.isOpenMp3 = false;
|
this.isOpenMp3 = false;
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user