xgplayer-mp4-loader 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/es/cache.d.ts +6 -0
- package/es/cache.js +32 -0
- package/es/config.d.ts +1 -0
- package/es/config.js +25 -0
- package/es/error.d.ts +6 -0
- package/es/error.js +11 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +5 -0
- package/es/loader.d.ts +42 -0
- package/es/loader.js +715 -0
- package/es/utils.d.ts +15 -0
- package/es/utils.js +280 -0
- package/package.json +27 -0
package/es/cache.d.ts
ADDED
package/es/cache.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
2
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
3
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
|
|
5
|
+
var Cache = /*#__PURE__*/function () {
|
|
6
|
+
function Cache() {
|
|
7
|
+
_classCallCheck(this, Cache);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "_data", Object.create(null));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
_createClass(Cache, [{
|
|
13
|
+
key: "set",
|
|
14
|
+
value: function set(id, data) {
|
|
15
|
+
this._data[id] = data;
|
|
16
|
+
}
|
|
17
|
+
}, {
|
|
18
|
+
key: "get",
|
|
19
|
+
value: function get(id) {
|
|
20
|
+
return this._data[id];
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
key: "clear",
|
|
24
|
+
value: function clear() {
|
|
25
|
+
this._data = Object.create(null);
|
|
26
|
+
}
|
|
27
|
+
}]);
|
|
28
|
+
|
|
29
|
+
return Cache;
|
|
30
|
+
}();
|
|
31
|
+
|
|
32
|
+
export { Cache };
|
package/es/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getConfig(cfg: any): any;
|
package/es/config.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import 'core-js/modules/es.object.keys.js';
|
|
2
|
+
import 'core-js/modules/es.symbol.js';
|
|
3
|
+
import 'core-js/modules/es.array.filter.js';
|
|
4
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
5
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
6
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
8
|
+
|
|
9
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
+
|
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
12
|
+
|
|
13
|
+
function getConfig(cfg) {
|
|
14
|
+
return _objectSpread(_objectSpread({
|
|
15
|
+
vid: '',
|
|
16
|
+
moovEnd: 8000,
|
|
17
|
+
segmentDuration: 5,
|
|
18
|
+
maxDownloadInfoSize: 30,
|
|
19
|
+
cache: null
|
|
20
|
+
}, cfg), {}, {
|
|
21
|
+
responseType: 'arraybuffer'
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { getConfig };
|
package/es/error.d.ts
ADDED
package/es/error.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
2
|
+
|
|
3
|
+
var MediaError = function MediaError(msg, data) {
|
|
4
|
+
_classCallCheck(this, MediaError);
|
|
5
|
+
|
|
6
|
+
this.type = 'file';
|
|
7
|
+
this.message = msg;
|
|
8
|
+
this.data = data;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { MediaError };
|
package/es/index.d.ts
ADDED
package/es/index.js
ADDED
package/es/loader.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export class MP4Loader {
|
|
2
|
+
constructor(config: any);
|
|
3
|
+
vid: string;
|
|
4
|
+
url: string;
|
|
5
|
+
meta: {};
|
|
6
|
+
downloadInfo: any[];
|
|
7
|
+
videoSegments: any[];
|
|
8
|
+
audioSegments: any[];
|
|
9
|
+
cache: any;
|
|
10
|
+
_currentSegmentIndex: number;
|
|
11
|
+
_currentLoadingSegmentIndex: number;
|
|
12
|
+
_config: any;
|
|
13
|
+
_loader: NetLoader;
|
|
14
|
+
get isMetaLoaded(): number;
|
|
15
|
+
setCurrentSegment(segIndex: any): void;
|
|
16
|
+
isLastSegment(segIndex: any): boolean;
|
|
17
|
+
isSegmentLoading(segIndex: any): boolean;
|
|
18
|
+
changeUrl(url: any, vid: any, moovEnd: any): Promise<void>;
|
|
19
|
+
getOrLoadMeta(cache: any): Promise<{}>;
|
|
20
|
+
loadMeta(cache: any, moovEnd: any): Promise<{
|
|
21
|
+
meta: {};
|
|
22
|
+
videoSegments: any[];
|
|
23
|
+
audioSegments: any[];
|
|
24
|
+
responses: any[];
|
|
25
|
+
}>;
|
|
26
|
+
getSegmentByTime(time: any): {
|
|
27
|
+
video: any;
|
|
28
|
+
audio: any;
|
|
29
|
+
};
|
|
30
|
+
loadSegmentByTime(time: any, cache: any, changeCurrent?: boolean): Promise<any>;
|
|
31
|
+
loadNextSegment(cache: any, changeCurrent?: boolean): Promise<any>;
|
|
32
|
+
preload(time: any): Promise<void>;
|
|
33
|
+
cancel(): Promise<void>;
|
|
34
|
+
reset(): Promise<void>;
|
|
35
|
+
destroy(): Promise<void>;
|
|
36
|
+
_loadSegment(video: any, audio: any, cache: any, changeCurrent: any): Promise<any>;
|
|
37
|
+
_loadData(range: any, cache: any): Promise<any>;
|
|
38
|
+
_downloadInfos: any[];
|
|
39
|
+
_transformError: (error: any) => any;
|
|
40
|
+
_getCacheKey(range: any): string;
|
|
41
|
+
}
|
|
42
|
+
import { NetLoader } from "xgplayer-streaming-shared/es/net";
|