视频添加倍速

This commit is contained in:
@fawn-nine
2024-07-02 11:27:48 +08:00
parent 3fe52975b5
commit cd34e5455e

View File

@@ -10,23 +10,12 @@
}px; left: ${10}px;z-index: 999;`"
></u-icon>-->
<view style="width: 100%; height: 200px" v-if="currentVideo.type == 1">
<div
class=""
style="background-color: #000"
ref="videoContent"
@tap="renderScript.handleClick"
id="url-player-test"
:videoData="videoData"
:winWidth="winWidth"
:winHeight="winHeight"
:currentVideoList="currentVideoList"
:firstTime="firstTime"
:change:videoData="renderScript.receiveMsg"
:change:winWidth="renderScript.receiveWinWidth"
:change:winHeight="renderScript.receiveWinHeight"
<div class="" style="background-color: #000" ref="videoContent" @tap="renderScript.handleClick"
id="url-player-test" :videoData="videoData" :winWidth="winWidth" :winHeight="winHeight"
:currentVideoList="currentVideoList" :firstTime="firstTime" :change:videoData="renderScript.receiveMsg"
:change:winWidth="renderScript.receiveWinWidth" :change:winHeight="renderScript.receiveWinHeight"
:change:firstTime="renderScript.receiveFirstTime"
:change:currentVideoList="renderScript.receiveVideoList"
></div>
:change:currentVideoList="renderScript.receiveVideoList"></div>
<div @tap="renderScript.emitData" ref="videoContent1" v-show="false">
直接调用renderjs中的emitData的方法,传递当前播放时长
</div>
@@ -35,26 +24,17 @@
</div>
<div class="fullScreenButton-container">
<div
:class="`prism-fullscreen-btn ${isFullScreen ? 'fullscreen' : ''}`"
@tap="renderScript.changeVideoScreen"
></div>
<div :class="`prism-fullscreen-btn ${isFullScreen ? 'fullscreen' : ''}`"
@tap="renderScript.changeVideoScreen"></div>
<!-- <div class="beisuBtn" id="beisuBtn" @tap="renderScript.changeSpeed">倍速</div> -->
<!-- <img class=" iconfont icon-list" src="../../../../static/icon/cate_bg.png" style="width: 60px;height: 10px;"></img> -->
</div>
<!-- <div class="beisuBtn" id="beisuBtn" @tap="renderScript.changeSpeed">倍速</div> -->
</view>
<view style="width: 100%; height: 200px; position: relative" v-else>
<video
@timeupdate="videoTimeUpdateEvent($event)"
ref="videos"
style="width: 100%; height: 100%"
autoplay
id="videoId"
object-fit="contain"
class="video-box"
:src="videoUrl"
:poster="`${videoUrl}?x-oss-process=video/snapshot,t_${1},f_jpg`"
@play="playVideo"
>
<video @timeupdate="videoTimeUpdateEvent($event)" ref="videos" style="width: 100%; height: 100%" autoplay
id="videoId" object-fit="contain" class="video-box" :src="videoUrl"
:poster="`${videoUrl}?x-oss-process=video/snapshot,t_${1},f_jpg`" @play="playVideo">
<cover-view style="position: absolute; top: 10px; z-index: 80">
<cover-view class="returnBack" @click="goBack">
<uni-icons type="back" size="26" color="#fff"></uni-icons>
@@ -79,11 +59,14 @@
</view>
</template>
<script>
import $http from "@/config/requestConfig.js";
import { mapState, mapMutations } from "vuex";
import $http from "@/config/requestConfig.js";
import {
mapState,
mapMutations
} from "vuex";
// importScripts('@/static/aliplayer/aliplayer-min.js')
export default {
// importScripts('@/static/aliplayer/aliplayer-min.js')
export default {
props: ["currentVideo", "currentVideoList"],
data() {
return {
@@ -227,9 +210,9 @@ export default {
this.videoData.userCourseVideoPositionEntity
);
if (!this.isSetFirstTime) {
var netWork = this.videoData.userCourseVideoPositionEntity
? this.videoData.userCourseVideoPositionEntity.position
: 0;
var netWork = this.videoData.userCourseVideoPositionEntity ?
this.videoData.userCourseVideoPositionEntity.position :
0;
var list = JSON.parse(uni.getStorageSync("videoOssList"));
console.log("这是获取接口 设置的起始时长", netWork);
var index = list.findIndex((e) => e.id == this.videoData.id);
@@ -379,24 +362,23 @@ export default {
},
created() {},
};
};
</script>
<script module="renderScript" lang="renderjs">
import $ from 'jquery'
// import StaticADComponent from './staticadcomponent/index.js';
/**
import $ from 'jquery'
// import StaticADComponent from './staticadcomponent/index.js';
/**
* 静态广告组件
*/
export default {
/**
* 静态广告组件
*/
export default {
/**
* 静态广告组件
*/
components: {
components: {
// MyComponent
},
mounted() {
@@ -429,11 +411,11 @@ components: {
handleClick(event, ownerInstance) {
console.log('event at line 165:', event)
// this.player.on('ready',function(){
// var status= this.player.fullscreenService.getIsFullScreen()
// console.log('status at line 403:', status)
// console.log('触发点击事件',status))
// })
// this.player.on('ready',function(){
// var status= this.player.fullscreenService.getIsFullScreen()
// console.log('status at line 403:', status)
// console.log('触发点击事件',status))
// })
ownerInstance.callMethod('getData')
@@ -450,62 +432,43 @@ components: {
changeVideoScreen(event, ownerInstance) {
var that = this;
// this.$emit('changeScreenLoading',true)
var status=this.player.fullscreenService.getIsFullScreen();
var status = this.player.fullscreenService.getIsFullScreen();
ownerInstance.callMethod('screenChange', {
status:status,
primary:status?'portrait':'landscape'
status: status,
primary: status ? 'portrait' : 'landscape'
})
if(status){
setTimeout(() => {
if (status) {
setTimeout(() => {
plus.screen.lockOrientation("portrait-primary"); //锁死屏幕方向为竖屏
this.player.fullscreenService.cancelFullScreen() ;
this.player.fullscreenService.cancelFullScreen();
// this.$emit('changeScreenLoading',false);
}, 100);
}, 100);
// this.player.setPlayerSize('100%','200px');
} else {
}else{
// this.player.setPlayerSize({
// w:"400px",
// height:'60%'
// });
// plus.screen.unlockOrientation();
this.player.fullscreenService.requestFullScreen();
// this.player.setPlayerSize({
// w:"400px",
// height:'60%'
// });
// plus.screen.unlockOrientation();
this.player.fullscreenService.requestFullScreen();
setTimeout(() => {
// this.$emit('changeScreenLoading',false);
plus.screen.lockOrientation("landscape-primary");
}, 100);
}
},
changeSpeed(event, ownerInstance){
console.log('点击了');
},
endEmitData(event, ownerInstance) {
var that = this;
ownerInstance.callMethod('handleEnd', )
},
getLive() {
if(this.videoData.type==1){
if (this.videoData.type == 1) {
var fullScreenButtonComponent = Aliplayer.Component({
/**
* 初始函数在new对象时调用
@@ -513,9 +476,9 @@ if(this.videoData.type==1){
* @param {string} adAddress - 广告视频地址
* @param {string} toAddress - 广告链接地址
*/
init: function (status, toAddress) {
init: function(status, toAddress) {
this.fullScreenStatus=status
this.fullScreenStatus = status
// this.adAddress = adAddress;
// this.toAddress = toAddress;
@@ -526,13 +489,13 @@ if(this.videoData.type==1){
/**
* 创建广告Dom元素
*/
createEl: function (el) {
createEl: function(el) {
this.$html.find('.ad').attr('src', this.adAddress);
var $adWrapper = this.$html.find('.ad-wrapper');
$adWrapper.attr('href', this.toAddress);
$adWrapper.click(function () {
$adWrapper.click(function() {
// Aliplayer.util.stopPropagation();
});
// this.$html.find('.close').click(function () {
@@ -541,44 +504,42 @@ if(this.videoData.type==1){
// $(el).find('.prism-controlbar').append(this.$html);
$(el).find('.prism-time-display').after(this.$html);
},
ready: function (player, e) {
ready: function(player, e) {
// this.$html.hide()
},
/**
* 隐藏广告
*/
play: function (player, e) {
play: function(player, e) {
// this.$html.show();
},
/**
* 显示广告
*/
pause: function (player, e) {
pause: function(player, e) {
// this.$html.show();
},
/**
* 隐藏广告
*/
playing: function (player, e) {
playing: function(player, e) {
this.$html.show();
// this.$html.hide();
},
waiting: function (player, e) {
waiting: function(player, e) {
// this.$html.hide()
},
timeupdate: function (player, e) {
},
error: function (player, e) {
},
timeupdate: function(player, e) {},
error: function(player, e) {},
/**
* 显示广告
*/
ended: function (player, e) {
ended: function(player, e) {
// this.$html.show();
}
});
});
console.log('this.currentVideoList at line 456111111111111111111111:', this.videoList)
console.log('this.currentVideoList at line 456111111111111111111111:', this.videoList)
var player = new Aliplayer({
id: "url-player-test",
"vid": this.videoData
@@ -592,50 +553,134 @@ console.log('this.currentVideoList at line 456111111111111111111111:', this.vide
// videoWidth: '100vw', //容器的大小
// videoHeight: '100vh', //容器的大小
height: '100%', //容器的大小
playsinline:true,
controlBarVisibility:"click",
cover:"",
playsinline: true,
controlBarVisibility: "click",
cover: "",
components: [
// {
// name: 'BulletScreenComponent',
// type: AliPlayerComponent.BulletScreenComponent,
// /** Descriptions of the scrolling text component parameters: text, style, bulletPosition
// * text: The scrolling text
// * style: The style of the scrolling text
// * bulletPosition: The position of the scrolling text. Valid values: 'top', 'bottom', and 'random'. The default is 'random'.
// */
// args: ['本课程版权归天津众妙之门科技有限公司所有,翻版必究!', {fontSize: '16px', color: 'red',}, 'random']
// },
{name:'adComponent',type:fullScreenButtonComponent,args:['http://101.201.146.165:8088/Pf-EH/statics/uploadFile/2024-05-10/b0f420c7-9178-41ad-9dd6-f59a64a6e190.png']},
// {
// name: 'BulletScreenComponent',
// type: AliPlayerComponent.BulletScreenComponent,
// /** Descriptions of the scrolling text component parameters: text, style, bulletPosition
// * text: The scrolling text
// * style: The style of the scrolling text
// * bulletPosition: The position of the scrolling text. Valid values: 'top', 'bottom', and 'random'. The default is 'random'.
// */
// args: ['本课程版权归天津众妙之门科技有限公司所有,翻版必究!', {fontSize: '16px', color: 'red',}, 'random']
// },
// {
// name: 'RotateMirrorComponent',
// type: AliPlayerComponent.RotateMirrorComponent
// },
],
skinLayout:[
{name: "bigPlayButton", align: "blabs", x: 30, y: 80},
{name: "H5Loading", align: "cc"},
{name: "errorDisplay", align: "tlabs", x: 0, y: 0},
{name: "infoDisplay"},
{name:"tooltip", align:"blabs",x: 0, y: 56},
{name: "thumbnail"},
{
name: "controlBar", align: "blabs", x: 0, y: 0,
children: [
{name: "progress", align: "blabs", x: 0, y: 44},
{name: "playButton", align: "tl", x: 15, y: 12},
{name: "timeDisplay", align: "tl", x: 10, y: 7},
name: 'adComponent',
type: fullScreenButtonComponent,
args: [
'http://101.201.146.165:8088/Pf-EH/statics/uploadFile/2024-05-10/b0f420c7-9178-41ad-9dd6-f59a64a6e190.png']
},
{
name: 'RateComponent',
type: AliPlayerComponent.RateComponent
},
// {
// name: 'adComponent1',
// type: beisuBtnComponent,
// args:['http://example.aliyundoc.com/cover.png']
// {
// name: 'X0.75',
// speed: 0.75
// }, {
// name: 'X1.0',
// speed: 1.0
// }, {
// name: 'X1.25',
// speed: 1.25
// }, {
// name: 'X1.5',
// speed: 1.5
// }, {
// name: 'X2.0',
// speed: 2.0
// },
// ]
// },
// {
// name: 'RotateMirrorComponent',
// type: AliPlayerComponent.RotateMirrorComponent
// },
],
skinLayout: [{
name: "bigPlayButton",
align: "blabs",
x: 30,
y: 80
},
{
name: "H5Loading",
align: "cc"
},
{
name: "errorDisplay",
align: "tlabs",
x: 0,
y: 0
},
{
name: "infoDisplay"
},
{
name: "tooltip",
align: "blabs",
x: 0,
y: 56
},
{
name: "thumbnail"
},
{
name: "controlBar",
align: "blabs",
x: 0,
y: 0,
children: [{
name: "progress",
align: "blabs",
x: 0,
y: 44
},
{
name: "playButton",
align: "tl",
x: 15,
y: 12
},
{
name: "timeDisplay",
align: "tl",
x: 10,
y: 7
},
// {name: "fullScreenButton", align: "tr", x: 10, y: 12},
// {name:"subtitle", align:"tr",x:15, y:12},
{name:"setting", align:"tr",x:15, y:12},
{name:"prism-speed-selector", align:"tr",x:15, y:12},
{name: "volume", align: "tr", x: 5, y: 10}
{
name: "setting",
align: "tr",
x: 15,
y: 12
},
{
name: "prism-speed-selector",
align: "tr",
x: 15,
y: 12
},
{
name: "volume",
align: "tr",
x: 5,
y: 10
}
]
}
]
@@ -651,23 +696,23 @@ console.log('this.currentVideoList at line 456111111111111111111111:', this.vide
this.player = player;
this.$refs.videoContent.click()
var timer = setInterval(() => {
var timer = setInterval(() => {
var that = this;
that.curTime = parseInt(this.player.getCurrentTime());
that.curStatus = this.player.getStatus()
}, 1000);
// player.on('ready',function(){
// player.fullscreenService.requestFullScreen()
}, 1000);
// player.on('ready',function(){
// player.fullscreenService.requestFullScreen()
// })
this.player.on('ended', function() {
// })
this.player.on('ended', function() {
console.log('that.curTime at line 242:', this.curTime)
console.log('that.curStatus at line 210:', this.curStatus)
this.$refs.videoContent2.click()
})
}
})
}
// player.setRotate(90)
@@ -733,13 +778,13 @@ this.player.on('ended', function() {
},
checkValue() {
console.log(this.videoId, this.authId, "1111888888")
if (!this.videoData.playAuth||!this.currentVideoList) {
if (!this.videoData.playAuth || !this.currentVideoList) {
setTimeout(() => {
this.checkValue();
}, 1000);
} else {
console.log('this.videoList at line 这是这只只是594:', this.currentVideoList)
console.log('this.videoList at line 这是这只只是594:', this.currentVideoList)
this.getLive();
}
},
@@ -755,7 +800,8 @@ console.log('this.videoList at line 这是这只只是594:', this.currentVideoLi
s_tag.onload = () => {
const s_tag1 = document.createElement('script'); // 引入播放器js
s_tag1.type = 'text/javascript';
s_tag1.src = 'https://player.alicdn.com/aliplayer/presentation/js/aliplayercomponents.min.js';
s_tag1.src =
'https://player.alicdn.com/aliplayer/presentation/js/aliplayercomponents.min.js';
s_tag1.charset = 'utf-8';
s_tag1.onload = () => {
this.checkValue();
@@ -794,75 +840,77 @@ console.log('this.videoList at line 这是这只只是594:', this.currentVideoLi
// });
}
}
}
}
</script>
<style>
.container {
.container {
width: 100vw;
height: auto;
/deep/.pause {
width: 60rpx !important;
height: 60rpx !important;
}
}
}
.fds {
.fds {
background-color: blue;
height: 600rpx;
position: fixed;
top: 60rpx;
}
}
.returnBack {
.returnBack {
flex-direction: row;
justify-content: flex-start;
align-items: center;
height: 88rpx;
padding-left: 20rpx;
}
}
.txt {
.txt {
color: #fff;
}
}
.right_title {
.right_title {
background: #000;
height: 96rpx;
justify-content: space-between;
flex-direction: row;
align-items: center;
margin-left: auto;
}
}
.return {
.return {
flex-direction: row;
align-items: center;
color: #fff;
}
}
.right_handle {
.right_handle {
width: 200rpx;
flex-direction: row;
justify-content: flex-end;
padding-right: 20rpx;
}
}
cover-view {
cover-view {
display: block;
line-height: 1.2;
overflow: hidden;
white-space: nowrap;
pointer-events: auto;
}
cover-view {
visibility: visible !important;
}
}
cover-image {
cover-view {
visibility: visible !important;
}
}
.fullScreenButton-container {
cover-image {
visibility: visible !important;
}
.fullScreenButton-container {
color: #fff;
float: right;
height: 35px;
@@ -871,6 +919,7 @@ cover-image {
display: flex;
align-items: center;
position: relative;
i {
color: #fff;
display: inline-block;
@@ -878,28 +927,35 @@ cover-image {
display: block;
margin-top: 7px;
cursor: pointer;
& + i {
&+i {
margin-left: 3px;
}
@media (min-width: 768px) {
&:hover + .player-tooltip {
&:hover+.player-tooltip {
display: block;
}
}
}
.player-tooltip {
&.prev {
left: -10px;
}
&.list {
left: 5px;
}
&.next {
right: -12px;
}
}
}
.playlist-content {
}
.playlist-content {
position: absolute;
right: 0;
width: 0px;
@@ -908,11 +964,13 @@ cover-image {
height: 100%;
transition: all 0.38s ease-in-out;
overflow: hidden;
.list {
background-color: #000;
background-color: rgba(0, 0, 0, 0.3);
height: 100%;
overflow: auto;
.video-item {
color: #fff;
padding: 0px 10px;
@@ -922,10 +980,12 @@ cover-image {
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
&.active {
background-color: #000;
color: #00ddff;
}
@media (min-width: 768px) {
&:hover {
background-color: #000;
@@ -934,9 +994,9 @@ cover-image {
}
}
}
}
}
.player-tooltip {
.player-tooltip {
position: absolute;
display: none;
font-size: 12px;
@@ -950,9 +1010,9 @@ cover-image {
top: -48px;
padding: 0 5px;
white-space: nowrap;
}
}
.playlist-skip-tip {
.playlist-skip-tip {
padding: 5px 15px;
position: absolute;
top: 50%;
@@ -965,17 +1025,21 @@ cover-image {
color: #000;
text-align: center;
transform: translate(-50%, -50%);
}
#rotating-div {
}
#rotating-div {
width: 100vw;
height: 100vh;
background-color: #3498db;
transform: rotate(90deg); /* 旋转90度 */
transform-origin: center center; /* 设置旋转中心点在div中心 */
position: fixed; /* 固定定位,全屏显示 */
transform: rotate(90deg);
/* 旋转90度 */
transform-origin: center center;
/* 设置旋转中心点在div中心 */
position: fixed;
/* 固定定位,全屏显示 */
left: 0;
top: 0;
bottom: 0;
right: 0;
}
}
</style>