@jxstjh/jhvideo
Version:
HTML5 jhvideo base on MPEG2-TS Stream Player
82 lines • 3.13 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { createDefaultControllerOpt } from "./model/playerModel";
import { createPtzControllerDom } from "./utils/controlDom";
import nipplejs from './utils/nipplejs';
import { getJoysticPositionFlag } from "./utils/ptzController";
var JPtzController = /** @class */ (function () {
function JPtzController(playerIns, el, controllerOpt) {
this.el = el;
this.controllerOpt = controllerOpt;
this.controllerOpt = __assign(__assign({}, createDefaultControllerOpt()), controllerOpt);
this._plyer = playerIns;
this.bindPlayer();
}
JPtzController.prototype.bindPlayer = function () {
var _this = this;
if (this._plyer) {
this._plyer.on('inited', function (vid, playerIns) {
var _a = playerIns && playerIns.streamOpt, isptz = _a.isptz, streamtype = _a.streamtype;
_this.initDom(isptz, streamtype);
});
}
};
JPtzController.prototype.emptyDom = function () {
var c = this.el.childNodes;
c.forEach(function (t) {
t.parentNode.removeChild(t);
});
};
JPtzController.prototype.initDom = function (isPtz, streamtype) {
var hideTools = this.controllerOpt.hideTools;
this.emptyDom();
var _a = createPtzControllerDom(this._plyer, hideTools, isPtz, streamtype), box = _a[0], toolbox = _a[1], joystick = _a[2];
this.el.appendChild(box);
this.toolbox_ele = toolbox;
this.joystick_ele = joystick;
if (streamtype === 'live' && isPtz) {
this.initJoystic();
}
};
JPtzController.prototype.initJoystic = function () {
var _this = this;
if (this.joystickIns) {
this.destroyJoystick();
}
var _a = this.el, clientHeight = _a.clientHeight, clientWidth = _a.clientWidth;
var size = Math.min(clientHeight, clientWidth) * 0.8;
var opt = {
zone: this.joystick_ele,
mode: 'static',
position: { left: '50%', top: '50%' },
jvideo: true,
size: size
};
this.joystickIns = nipplejs.create(opt);
this.joystickIns.on('dir:up dir:down dir:left dir:right end', function (evt, data) {
if (evt.type === 'end') {
setTimeout(function () {
_this._plyer.sendPtzCmd(-1);
}, 26);
}
else {
var f = getJoysticPositionFlag(evt.type);
_this._plyer.sendPtzCmd(f);
}
});
};
JPtzController.prototype.destroyJoystick = function () {
};
return JPtzController;
}());
export default JPtzController;
//# sourceMappingURL=jptzController.js.map