1 Star 0 Fork 1

赌神/TcpPlayer_Uniapp

forked from 超长/TcpPlayer_Uniapp 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.vue 2.43 KB
一键复制 编辑 原始数据 按行查看 历史
超长 提交于 2020-08-21 15:39 . init
<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>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/cc_vinci/tcp-player_-uniapp.git
git@gitee.com:cc_vinci/tcp-player_-uniapp.git
cc_vinci
tcp-player_-uniapp
TcpPlayer_Uniapp
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385