Commit e81a620b authored by liujiangnan's avatar liujiangnan

feat: 各种控制

parent 8acca360
This diff is collapsed.
...@@ -160,10 +160,12 @@ cc.Class({ ...@@ -160,10 +160,12 @@ cc.Class({
}); });
this.videoPlayer.node.on('meta-loaded', () => { this.videoPlayer.node.on('meta-loaded', () => {
console.log('meta-loaded'); console.log('meta-loaded');
cc.find(`Canvas/bg_video_shadow`).active = false;
this._isReadyToPlay = true; this._isReadyToPlay = true;
this.durationLabel.string = this.formatTime(this.videoPlayer.getDuration()); this.durationLabel.string = this.formatTime(this.videoPlayer.getDuration());
this.videoPlayer.currentTime = 0;
// this.videoPlayer.resume(); // this.videoPlayer.resume();
this.videoPlayer.play(); this.play();
}); });
this.videoPlayer.node.on('clicked', () => { this.videoPlayer.node.on('clicked', () => {
console.log('clicked'); console.log('clicked');
...@@ -306,12 +308,22 @@ cc.Class({ ...@@ -306,12 +308,22 @@ cc.Class({
}, },
// 选择视频播放 // 选择视频播放
async clickVideoItem(evt) { async clickVideoItem(evt) {
this._isReadyToPlay = false; const item = evt.currentTarget;
const item = evt.currentTarget;
if (!item.video_url) { if (!item.video_url) {
this.showTips("视频不存在"); this.showTips("视频不存在");
return;
}
if (item.video_url == this.videoPlayer.remoteURL) {
this.showTips("该视频正在播放");
return; return;
} }
this._isReadyToPlay = false;
cc.find(`Canvas/bg`).active = true;
cc.find(`Canvas/bgwhite`).active = true;
cc.find(`Canvas/bg_video_shadow`).active = true;
this.videoPlayer.node.x = -5000;
this.videoPlayer.node.y = -5000;
cc.find(`Canvas/videolist/view/content`).children.forEach(row => { cc.find(`Canvas/videolist/view/content`).children.forEach(row => {
cc.find(`item_active`, row).active = false; cc.find(`item_active`, row).active = false;
}); });
...@@ -405,16 +417,16 @@ cc.Class({ ...@@ -405,16 +417,16 @@ cc.Class({
return; return;
} }
const {width, height} = cc.find(`Canvas/bg`); const {width, height} = cc.find(`Canvas/bg`);
cc.find(`Canvas/Controls/ProgressBar/text_tips_left`).active = false; cc.find(`Canvas/Controls/ProgressBar/text_tips`).active = false;
cc.find(`Canvas/bg`).active = false; cc.find(`Canvas/bg`).active = false;
cc.find(`Canvas/bgwhite`).active = false; cc.find(`Canvas/bgwhite`).active = false;
cc.find(`Canvas/bg_empty`).active = false; cc.find(`Canvas/bg_video_shadow`).active = false;
cc.find('Canvas/video_node/bg').width = width; const videoContainer = cc.find('Canvas/video_node');
cc.find('Canvas/video_node/bg').height = height; cc.find('bg', videoContainer).width = width;
this.videoPlayer.node.x = 0; cc.find('bg', videoContainer).height = height;
this.videoPlayer.node.y = 0; this.videoPlayer.node.x = videoContainer.x;
// this.videoPlayer.node.active = true; this.videoPlayer.node.y = videoContainer.y;
this.videoPlayer.play(); this.videoPlayer.play();
}, },
pause(){ pause(){
...@@ -438,23 +450,41 @@ cc.Class({ ...@@ -438,23 +450,41 @@ cc.Class({
time1: null, time1: null,
isVideoFull: false, isVideoFull: false,
tempPos: null,
fullScreen() { fullScreen() {
if (this.isVideoFull) { if (this.isVideoFull) {
return; return;
} }
if (!this._isReadyToPlay) {
return;
}
this.tempPos = {};
console.log("====进入全屏==="); console.log("====进入全屏===");
this.isVideoFull = true; this.isVideoFull = true;
this.videoPlayer.stayOnBottom = true; this.videoPlayer.stayOnBottom = true;
cc.find(`Canvas/Controls/fullscreen`).active = !this.isVideoFull; cc.find(`Canvas/Controls/fullscreen`).active = !this.isVideoFull;
cc.find(`Canvas/Controls/exitfull`).active = this.isVideoFull; cc.find(`Canvas/Controls/exitfull`).active = this.isVideoFull;
cc.find(`Canvas/video_node`).width = this.node.width; const videoContainer = cc.find('Canvas/video_node');
cc.find(`Canvas/video_node`).height = this.node.height; this.tempPos.videoPos = {x: videoContainer.x, y: videoContainer.y, width: videoContainer.width, height: videoContainer.height};
cc.find(`Canvas/bg_empty`).width = this.node.width; videoContainer.width = this.node.width;
cc.find(`Canvas/bg_empty`).height = this.node.height; videoContainer.height = this.node.height;
videoContainer.x = 0;
videoContainer.y = 0;
cc.find(`Canvas/videolist`).active = false;
const controls = cc.find(`Canvas/Controls`);
this.tempPos.controlPos = {x: controls.x, y: controls.y};
cc.find(`bg_video_bottom`, controls).active = false;
controls.x = 0;
controls.y = 0 - this.node.height / 2 + 130;
this.videoPlayer.node.height = this.node.height; this.videoPlayer.node.height = this.node.height;
this.videoPlayer.node.width = this.node.width; this.videoPlayer.node.width = this.node.width;
this.videoPlayer.node.x = 0;
this.videoPlayer.node.y = 0;
setTimeout(() => { setTimeout(() => {
// IOS下视频的全屏适配比例有问题,所以做一个计算 // IOS下视频的全屏适配比例有问题,所以做一个计算
this.videoPlayer.node.width = Math.min(this.node.width, this.node.height*16/9); this.videoPlayer.node.width = Math.min(this.node.width, this.node.height*16/9);
...@@ -470,19 +500,29 @@ cc.Class({ ...@@ -470,19 +500,29 @@ cc.Class({
if (!this.isVideoFull) { if (!this.isVideoFull) {
return; return;
} }
console.log("====退出全屏==="); console.log("====退出全屏===", this.tempPos);
this.isVideoFull = false; this.isVideoFull = false;
cc.find(`Canvas/Controls/fullscreen`).active = !this.isVideoFull; cc.find(`Canvas/Controls/fullscreen`).active = !this.isVideoFull;
cc.find(`Canvas/Controls/exitfull`).active = this.isVideoFull; cc.find(`Canvas/Controls/exitfull`).active = this.isVideoFull;
cc.find(`Canvas/video_node`).width = 1377; const videoContainer = cc.find('Canvas/video_node');
cc.find(`Canvas/video_node`).height = 775; videoContainer.width = this.tempPos.videoPos.width;
cc.find(`Canvas/bg_empty`).width = 1377; videoContainer.height = this.tempPos.videoPos.height;
cc.find(`Canvas/bg_empty`).height = 775; videoContainer.x = this.tempPos.videoPos.x;
videoContainer.y = this.tempPos.videoPos.y;
this.videoPlayer.node.width = 1377; this.videoPlayer.node.width = this.tempPos.videoPos.width;
this.videoPlayer.node.height = 775; this.videoPlayer.node.height = this.tempPos.videoPos.height;
this.videoPlayer.node.x = videoContainer.x;
this.videoPlayer.node.y = videoContainer.y;
cc.find(`Canvas/videolist`).active = true;
const controls = cc.find(`Canvas/Controls`);
cc.find(`bg_video_bottom`, controls).active = true;
controls.x = this.tempPos.controlPos.x;
controls.y = this.tempPos.controlPos.y;
if(this.time1) { if(this.time1) {
clearTimeout(this.time1); clearTimeout(this.time1);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment