代码拉取完成,页面将自动刷新
<template>
<view class="content">
<view id="demo"></view>
<div class="time-bt">
<button @click="start()">播放</button>
<button @click="stop()">暂停</button>
当前时间:{{ currentTime || '-' }}
</div>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello',
tcPlayerId: 'id_test_video',
fileID: undefined,
player: null,
currentTime: 0
};
},
mounted() {
// 初始化腾讯云播放器
var that = this;
uni.request({
url: 'xxxxxxx',//获取文件fileID
data: n,
success: (t) => {
if (1 == t.data.result) {
uni.getSystemInfo({
success: res => {
that.barHeight = 'padding-top:' + (res.statusBarHeight + 10) + 'px';
that.windowWidth = res.windowWidth;
that.windowHeight = res.windowHeight;
var x = document.createElement("video");
x.setAttribute("id", "player_id");
x.setAttribute("width", res.windowWidth);
x.setAttribute("height", res.windowHeight);
x.setAttribute("preload", "auto");
x.setAttribute("poster", '');
x.setAttribute("x5-video-player-type", "h5");
x.setAttribute("x5-video-player-fullscreen", true);
x.setAttribute("show-center-play-btn", false);
x.setAttribute("x5-playsinline", '');
x.setAttribute("x5-video-orientation", 'portrait');
x.setAttribute("playsinline", '');
x.setAttribute("webkit-playsinline", "auto");
document.getElementById("demo").appendChild(x);
console.log(x)
var player = TCPlayer('player_id', {
fileID: 'xxxxxx',//通过请求获取的fileID
appID: '0123456789',
autoplay: true,
controls: false,
loop: true,
plugins: {
ContinuePlay: { // 开启续播功能
auto: true, //[可选] 是否在视频播放后自动续播
text: '上次播放至', //[可选] 提示文案
btnText: '恢复播放' //[可选] 按钮文案
},
}
})
that.player = player;
}
});
}
}
});
},
methods: {
start() {
this.player.play();
},
stop() {
this.player.pause();
},
jump() {
this.seek(this.seekTime);
},
seek(s) {
this.player.currentTime(Number(s));
},
loop() {
this.seek(this.startTime);
}
}
};
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。