first commit

This commit is contained in:
编码猿
2024-09-27 01:25:59 +08:00
commit 546fffb620
78 changed files with 30293 additions and 0 deletions

307
dist/core/ui/controls.ui.js vendored Normal file
View File

@@ -0,0 +1,307 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ControlsUi = void 0;
var OptionParams_model_1 = require("../model/OptionParams.model");
var index_utils_1 = require("../utils/index.utils");
var Ioc_annotation_1 = require("../annotation/Ioc.annotation");
var Dom_annotation_1 = require("../annotation/Dom.annotation");
var ClassName_config_1 = require("../config/ClassName.config");
/**
* 底部控件条的基础功能设置
*/
var ControlsUi = /** @class */ (function () {
function ControlsUi() {
}
/**
* 播放按钮被点击,播放视频
* @constructor
*/
ControlsUi.prototype.BindEventPlay = function () {
var _this = this;
this.Play.onclick = function () { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!this.Video.paused) return [3 /*break*/, 2];
return [4 /*yield*/, this.Video.play()];
case 1:
_a = _b.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, this.Video.pause()];
case 3:
_a = _b.sent();
_b.label = 4;
case 4:
_a;
this.Play.classList.toggle(ClassName_config_1.ClassName.Stop);
return [2 /*return*/];
}
});
}); };
};
ControlsUi.prototype.BindEventPlayList = function () {
var _this = this;
var SideMenu = this.Utils.$("." + ClassName_config_1.ClassName.SideMenu);
this.playList.onclick = function () { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (SideMenu.style.right == "0px") {
this.Utils.$("." + ClassName_config_1.ClassName.SideMenu).style.right = '-250px';
}
else {
this.Utils.$("." + ClassName_config_1.ClassName.SideMenu).style.right = '0';
}
return [2 /*return*/];
});
}); };
};
/**
* 视频全屏
* @constructor
*/
ControlsUi.prototype.BindEventFullScreen = function () {
var _this = this;
this.FullScreen.onclick = function () { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!!document.fullscreenElement) return [3 /*break*/, 2];
this.Video.parentElement.style.width = '100%';
this.Video.parentElement.style.height = '100%';
return [4 /*yield*/, document.documentElement.requestFullscreen()];
case 1:
_a.sent();
return [3 /*break*/, 4];
case 2:
if (!document.exitFullscreen) return [3 /*break*/, 4];
this.Video.parentElement.style.width = OptionParams_model_1.default.OptionParams.width;
this.Video.parentElement.style.height = OptionParams_model_1.default.OptionParams.height;
return [4 /*yield*/, document.exitFullscreen()];
case 3:
_a.sent();
_a.label = 4;
case 4:
this.FullScreen.classList.toggle(ClassName_config_1.ClassName.Active);
return [2 /*return*/];
}
});
}); };
};
/**
* 截图按钮
* @constructor
*/
ControlsUi.prototype.BindEventScreenShot = function () {
var _this = this;
var scale = 0.65;
this.ScreenShot.onclick = function () {
var canvas = document.createElement("canvas");
canvas.width = _this.Video.videoWidth * scale;
canvas.height = _this.Video.videoHeight * scale;
canvas.getContext('2d')
.drawImage(_this.Video, 0, 0, canvas.width, canvas.height);
_this.Utils.downLoadFile(canvas.toDataURL('image/jpeg', 1.0), 'image/jpeg');
};
};
/**
* 循环播放的开关
* @constructor
*/
ControlsUi.prototype.BindEventLoop = function () {
var _this = this;
this.Loop.onclick = function () {
_this.Video.loop ? _this.Video.loop = false : _this.Video.loop = true;
_this.Loop.classList.toggle(ClassName_config_1.ClassName.Active);
};
};
/**
* 视频镜像功能
* @constructor
*/
ControlsUi.prototype.BindEventImage = function () {
var _this = this;
// 延迟解决 ondblclick 时候会触发 onclick 的问题
var ImageStatus = true, timeId = null; // true rotateY 镜像false rotateX 镜像
// 双击视频恢复
this.Image.ondblclick = function () {
clearTimeout(timeId);
ImageStatus = true;
_this.Video.style.cssText = "\n transform: rotateY(0deg); \n ";
};
// 单击镜像
this.Image.onclick = function () {
clearTimeout(timeId);
timeId = setTimeout(function () {
if (ImageStatus) {
ImageStatus = false;
_this.Video.style.cssText = "\n transform: rotateY(180deg); \n ";
}
else {
ImageStatus = true;
_this.Video.style.cssText = "\n transform: rotateX(180deg); \n ";
}
}, 250);
};
};
/**
* TODO 视频倍速的功能 实现中...
* @constructor
*/
ControlsUi.prototype.BindEventSpeed = function () {
// 默认视频倍速
var defaultSpeed = [0.5, 1.0, 1.25, 1.5, 2.0];
this.Speed.onclick = function () {
// 如果传入的是数组
if (Array.isArray(OptionParams_model_1.default.OptionParams.controls.speed)) {
defaultSpeed = OptionParams_model_1.default.OptionParams.controls.speed;
console.log("如果传入的是数组");
// 如果传入的是true表示开启默认的倍速播放功能
}
else if (OptionParams_model_1.default.OptionParams.controls.speed == true) {
console.log("表示开启默认的倍速播放功能");
}
};
};
/**
* 画中画
* @constructor
*/
ControlsUi.prototype.BindEventPictureInPicture = function () {
var _this = this;
this.PictureInPicture.onclick = function () {
if (document.pictureInPictureElement == null) {
_this.Video.requestPictureInPicture();
_this.PictureInPicture.classList.add(ClassName_config_1.ClassName.Active);
}
else {
document.exitPictureInPicture();
_this.PictureInPicture.classList.remove(ClassName_config_1.ClassName.Active);
}
};
/**
* 监听退出画中画功能
*/
this.Video.addEventListener('leavepictureinpicture', function () {
_this.PictureInPicture.classList.remove(ClassName_config_1.ClassName.Active);
_this.Play.classList.toggle(ClassName_config_1.ClassName.Stop);
});
};
/**
* 视频旋转
* @constructor
*/
ControlsUi.prototype.BindEventRotate = function () {
var _this = this;
var currentRotate = 0, RotateNumber = 0;
this.Rotate.onclick = function () {
if (RotateNumber >= 4) {
currentRotate = 0;
RotateNumber = 0;
}
currentRotate += OptionParams_model_1.default.OptionParams.controls.rotate == true
? 90
: OptionParams_model_1.default.OptionParams.controls.rotate;
RotateNumber++;
if (currentRotate == 180 || currentRotate == 360 ||
currentRotate == -180 || currentRotate == -360) {
_this.Video.style.cssText = "\n width: 100%;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%) rotate(" + currentRotate + "deg);\n ";
return false;
}
else {
// 视频旋转 90°270°后视频的宽度 等于 父元素的高度
_this.Video.style.cssText = "\n width: " + OptionParams_model_1.default.OptionParams.height + ";\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%) rotate(" + currentRotate + "deg);\n ";
}
};
};
__decorate([
Dom_annotation_1.Dom(),
__metadata("design:type", HTMLElement)
], ControlsUi.prototype, "Play", void 0);
__decorate([
Dom_annotation_1.Dom(),
__metadata("design:type", Object)
], ControlsUi.prototype, "Video", void 0);
__decorate([
Dom_annotation_1.Dom(),
__metadata("design:type", HTMLElement)
], ControlsUi.prototype, "Loop", void 0);
__decorate([
Dom_annotation_1.Dom(),
__metadata("design:type", HTMLElement)
], ControlsUi.prototype, "PictureInPicture", void 0);
__decorate([
Dom_annotation_1.Dom(),
__metadata("design:type", HTMLElement)
], ControlsUi.prototype, "Rotate", void 0);
__decorate([
Dom_annotation_1.Dom(),
__metadata("design:type", HTMLLIElement)
], ControlsUi.prototype, "Image", void 0);
__decorate([
Dom_annotation_1.Dom(),
__metadata("design:type", HTMLLIElement)
], ControlsUi.prototype, "ScreenShot", void 0);
__decorate([
Dom_annotation_1.Dom(),
__metadata("design:type", HTMLLIElement)
], ControlsUi.prototype, "Speed", void 0);
__decorate([
Dom_annotation_1.Dom(),
__metadata("design:type", HTMLLIElement)
], ControlsUi.prototype, "FullScreen", void 0);
__decorate([
Dom_annotation_1.Dom(),
__metadata("design:type", HTMLLIElement)
], ControlsUi.prototype, "playList", void 0);
__decorate([
Ioc_annotation_1.Inject(),
__metadata("design:type", index_utils_1.Utils)
], ControlsUi.prototype, "Utils", void 0);
return ControlsUi;
}());
exports.ControlsUi = ControlsUi;