UNPKG

@jxstjh/jhvideo

Version:

HTML5 jhvideo base on MPEG2-TS Stream Player

159 lines 5.24 kB
/* * Copyright (C) 2016 Bilibili. All Rights Reserved. * * @author zheng qian <xqq@xqq.im> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { NotImplementedException } from '../utils/exception.js'; export var LoaderStatus = { kIdle: 0, kConnecting: 1, kBuffering: 2, kError: 3, kComplete: 4 }; export var LoaderErrors = { OK: 'OK', EXCEPTION: 'Exception', HTTP_STATUS_CODE_INVALID: 'HttpStatusCodeInvalid', CONNECTING_TIMEOUT: 'ConnectingTimeout', EARLY_EOF: 'EarlyEof', UNRECOVERABLE_EARLY_EOF: 'UnrecoverableEarlyEof', STRING_DATA: 'StringData', JSON_DATA: 'jsonData' }; /* Loader has callbacks which have following prototypes: * function onContentLengthKnown(contentLength: number): void * function onURLRedirect(url: string): void * function onDataArrival(chunk: ArrayBuffer, byteStart: number, receivedLength: number): void * function onError(errorType: number, errorInfo: {code: number, msg: string}): void * function onComplete(rangeFrom: number, rangeTo: number): void */ var BaseLoader = /** @class */ (function () { function BaseLoader(typeName) { this._type = typeName || 'undefined'; this._status = LoaderStatus.kIdle; this._needStash = false; // callbacks this._onContentLengthKnown = null; this._onURLRedirect = null; this._onDataArrival = null; this._onError = null; this._onComplete = null; this._information = null; } BaseLoader.prototype.destroy = function () { this._status = LoaderStatus.kIdle; this._onContentLengthKnown = null; this._onURLRedirect = null; this._onDataArrival = null; this._onError = null; this._onComplete = null; this._information = null; }; BaseLoader.prototype.isWorking = function () { return this._status === LoaderStatus.kConnecting || this._status === LoaderStatus.kBuffering; }; Object.defineProperty(BaseLoader.prototype, "type", { get: function () { return this._type; }, enumerable: false, configurable: true }); Object.defineProperty(BaseLoader.prototype, "status", { get: function () { return this._status; }, enumerable: false, configurable: true }); Object.defineProperty(BaseLoader.prototype, "needStashBuffer", { get: function () { return this._needStash; }, enumerable: false, configurable: true }); Object.defineProperty(BaseLoader.prototype, "onContentLengthKnown", { get: function () { return this._onContentLengthKnown; }, set: function (callback) { this._onContentLengthKnown = callback; }, enumerable: false, configurable: true }); Object.defineProperty(BaseLoader.prototype, "onURLRedirect", { get: function () { return this._onURLRedirect; }, set: function (callback) { this._onURLRedirect = callback; }, enumerable: false, configurable: true }); Object.defineProperty(BaseLoader.prototype, "onDataArrival", { get: function () { return this._onDataArrival; }, set: function (callback) { this._onDataArrival = callback; }, enumerable: false, configurable: true }); Object.defineProperty(BaseLoader.prototype, "onError", { get: function () { return this._onError; }, set: function (callback) { this._onError = callback; }, enumerable: false, configurable: true }); Object.defineProperty(BaseLoader.prototype, "onComplete", { get: function () { return this._onComplete; }, set: function (callback) { this._onComplete = callback; }, enumerable: false, configurable: true }); Object.defineProperty(BaseLoader.prototype, "onInformation", { get: function () { return this._information; }, set: function (callback) { this._information = callback; }, enumerable: false, configurable: true }); // pure virtual BaseLoader.prototype.open = function (dataSource, range) { throw new NotImplementedException('Unimplemented abstract function!'); }; BaseLoader.prototype.abort = function () { throw new NotImplementedException('Unimplemented abstract function!'); }; return BaseLoader; }()); export { BaseLoader }; //# sourceMappingURL=loader.js.map