You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
152 lines
5.0 KiB
TypeScript
152 lines
5.0 KiB
TypeScript
|
3 years ago
|
// import { CommonCtrl } from "../CommonCtrl";
|
||
|
|
// import { GameSocket } from "../GameSocket";
|
||
|
|
// import TableMgr from "../managers/TableMgr";
|
||
|
|
// import { CommonUIs, UIManager } from "../managers/UIManager";
|
||
|
|
// import { Socket } from "./Socket/Socket";
|
||
|
|
// import { VideoFilterList } from "./VideoFilterList";
|
||
|
|
|
||
|
|
// const {ccclass, property} = cc._decorator;
|
||
|
|
|
||
|
|
// @ccclass
|
||
|
|
// export default class BaseVideoPlayer extends cc.Component {
|
||
|
|
// public sprite: cc.Sprite = null;
|
||
|
|
// protected loadingNode: cc.Node = null;
|
||
|
|
// protected videoBg: cc.Node = null;
|
||
|
|
// protected _filterName: string = "";
|
||
|
|
// protected url: string = '';
|
||
|
|
// public isPlaying: boolean = false;
|
||
|
|
// protected isReady: boolean = false;
|
||
|
|
// protected timeoutHandler: any;
|
||
|
|
// protected videoErrorCounts: number = 0;
|
||
|
|
// protected videoElementList: Array<HTMLElement> = [];
|
||
|
|
// private _m00: number = 0;
|
||
|
|
// private _m01: number = 0;
|
||
|
|
// private _m04: number = 0;
|
||
|
|
// private _m05: number = 0;
|
||
|
|
// private _m12: number = 0;
|
||
|
|
// private _m13: number = 0;
|
||
|
|
// private _w: number = 0;
|
||
|
|
// private _h: number = 0;
|
||
|
|
// protected get checkURLValid(): boolean {
|
||
|
|
// return new Date().getTime() < CommonCtrl.inst.videoConfig.lTime;
|
||
|
|
// }
|
||
|
|
|
||
|
|
// // init set video Sprite or Node
|
||
|
|
// public setSprite(sprite: cc.Sprite, loadingNode: cc.Node, videoBg: cc.Node = null): void {
|
||
|
|
// this.loadingNode = loadingNode;
|
||
|
|
// this.sprite = sprite;
|
||
|
|
// this.videoBg = videoBg;
|
||
|
|
// }
|
||
|
|
|
||
|
|
// // videoBg show
|
||
|
|
// protected setVideoBg(flag: boolean): void {
|
||
|
|
// this.videoBg && (this.videoBg.active = flag);
|
||
|
|
// }
|
||
|
|
|
||
|
|
// // load icon show
|
||
|
|
// protected setLoading(flag: boolean): void {
|
||
|
|
// this.loadingNode && (this.loadingNode.active = flag);
|
||
|
|
// }
|
||
|
|
|
||
|
|
// /** set video bg with load icon */
|
||
|
|
// protected setVideoBgWithLoad(flag: boolean): void {
|
||
|
|
// this.setVideoBg(flag);
|
||
|
|
// this.setLoading(flag);
|
||
|
|
// }
|
||
|
|
|
||
|
|
// protected stop(): void {}
|
||
|
|
// protected updateUrl(url: string): void {}
|
||
|
|
|
||
|
|
// public updateVideoCanvas(): void {
|
||
|
|
// // cc.log("updateVideoCanvas", CommonCtrl.inst.curDeviceType.isLandscape);
|
||
|
|
// const node = this.sprite?.node;
|
||
|
|
// if (!node) return;
|
||
|
|
|
||
|
|
// let _mat4_temp = cc.mat4();
|
||
|
|
// node.getWorldMatrix(_mat4_temp);
|
||
|
|
|
||
|
|
// let renderCamera = cc.Camera['_findRendererCamera'](node);
|
||
|
|
// if (renderCamera) {
|
||
|
|
// renderCamera.worldMatrixToScreen(_mat4_temp, _mat4_temp, cc.game.canvas.width, cc.game.canvas.height);
|
||
|
|
// }
|
||
|
|
|
||
|
|
// let _mat4_tempm = _mat4_temp.m;
|
||
|
|
// if (
|
||
|
|
// this._m00 === _mat4_tempm[0] && this._m01 === _mat4_tempm[1] &&
|
||
|
|
// this._m04 === _mat4_tempm[4] && this._m05 === _mat4_tempm[5] &&
|
||
|
|
// this._m12 === _mat4_tempm[12] && this._m13 === _mat4_tempm[13] &&
|
||
|
|
// this._w === node['_contentSize'].width && this._h === node['_contentSize'].height) {
|
||
|
|
// return;
|
||
|
|
// }
|
||
|
|
// this._m00 = _mat4_tempm[0];
|
||
|
|
// this._m01 = _mat4_tempm[1];
|
||
|
|
// this._m04 = _mat4_tempm[4];
|
||
|
|
// this._m05 = _mat4_tempm[5];
|
||
|
|
// this._m12 = _mat4_tempm[12];
|
||
|
|
// this._m13 = _mat4_tempm[13];
|
||
|
|
|
||
|
|
// this._w = node['_contentSize'].width;
|
||
|
|
// this._h = node['_contentSize'].height;
|
||
|
|
|
||
|
|
// let dpr = cc.view.getDevicePixelRatio();
|
||
|
|
// let scaleX = 1 / dpr;
|
||
|
|
// let scaleY = 1 / dpr;
|
||
|
|
|
||
|
|
// let a = _mat4_tempm[0] * scaleX,
|
||
|
|
// b = _mat4_tempm[1],
|
||
|
|
// c = _mat4_tempm[4],
|
||
|
|
// d = _mat4_tempm[5] * scaleY;
|
||
|
|
|
||
|
|
// let container = cc.game.container;
|
||
|
|
// let offsetX = container && container.style.paddingLeft ? parseInt(container.style.paddingLeft) : 0;
|
||
|
|
// let offsetY = container && container.style.paddingBottom ? parseInt(container.style.paddingBottom) : 0;
|
||
|
|
|
||
|
|
// let w = this._w * scaleX;
|
||
|
|
// let h = this._h * scaleY;
|
||
|
|
|
||
|
|
// let appx = (w * _mat4_tempm[0]) * node['_anchorPoint'].x;
|
||
|
|
// let appy = (h * _mat4_tempm[5]) * node['_anchorPoint'].y;
|
||
|
|
|
||
|
|
// let tx = _mat4_tempm[12] * scaleX - appx + offsetX, ty = _mat4_tempm[13] * scaleY - appy + offsetY;
|
||
|
|
|
||
|
|
// let matrix = "matrix(" + a + "," + -b + "," + -c + "," + d + "," + tx + "," + -ty + ")";
|
||
|
|
// this.videoElementList.forEach(item => {
|
||
|
|
// const video = item;
|
||
|
|
// video.style.width = this._w + 'px';
|
||
|
|
// video.style.height = this._h + 'px';
|
||
|
|
// video.style['transform'] = matrix;
|
||
|
|
// video.style['-webkit-transform'] = matrix;
|
||
|
|
// video.style['transform-origin'] = '0px 100% 0px';
|
||
|
|
// video.style['-webkit-transform-origin'] = '0px 100% 0px';
|
||
|
|
// })
|
||
|
|
|
||
|
|
// }
|
||
|
|
|
||
|
|
// private updateFilter(tableNo: string = "", data = { brightness: 100, contrast: 100, saturate: 100 }): void {
|
||
|
|
// cc.warn(`${tableNo} video filter`, data);
|
||
|
|
// this.videoElementList.forEach(video => {
|
||
|
|
// video.style.filter =
|
||
|
|
// `brightness(${data.brightness}%) ` +
|
||
|
|
// `contrast(${data.contrast}%) ` +
|
||
|
|
// `saturate(${data.saturate}%) ` +
|
||
|
|
// ``;
|
||
|
|
// })
|
||
|
|
// }
|
||
|
|
|
||
|
|
// public updateFilterByTableNo(tableNo: string = ""): void {
|
||
|
|
// if (this._filterName != tableNo) {
|
||
|
|
// this._filterName = tableNo;
|
||
|
|
// this.updateFilter(tableNo, VideoFilterList.get(tableNo));
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
|
||
|
|
// public retry(): void{
|
||
|
|
// this.stop();
|
||
|
|
// this.setLoading(true);
|
||
|
|
// this.scheduleOnce(()=>{
|
||
|
|
// this.updateUrl(CommonCtrl.inst.videoConfig.url);
|
||
|
|
// }, 10)
|
||
|
|
// GameSocket.inst.C2S_QueryLiveUrl();
|
||
|
|
// }
|
||
|
|
// }
|