@cycjimmy/jsmpeg-player 5.0.1 → 5.1.0
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 +0 -4
- package/dist/jsmpeg-player.cjs.js +30 -76
- package/dist/jsmpeg-player.esm.js +31 -77
- package/dist/jsmpeg-player.umd.js +33 -79
- package/dist/jsmpeg-player.umd.min.js +3 -3
- package/package.json +23 -23
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
-
(global = global || self, global.JSMpeg = factory());
|
|
5
|
-
}(this, (function () { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.JSMpeg = factory());
|
|
5
|
+
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _extends() {
|
|
8
8
|
_extends = Object.assign || function (target) {
|
|
@@ -25,73 +25,33 @@
|
|
|
25
25
|
function _inheritsLoose(subClass, superClass) {
|
|
26
26
|
subClass.prototype = Object.create(superClass.prototype);
|
|
27
27
|
subClass.prototype.constructor = subClass;
|
|
28
|
-
subClass.__proto__ = superClass;
|
|
29
|
-
}
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
29
|
+
_setPrototypeOf(subClass, superClass);
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
function _setPrototypeOf(o, p) {
|
|
33
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
34
|
+
o.__proto__ = p;
|
|
35
|
+
return o;
|
|
36
|
+
};
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
return _setPrototypeOf(o, p);
|
|
39
|
+
}
|
|
40
40
|
|
|
41
|
-
Object.defineProperty(exports, "__esModule", {
|
|
42
|
-
value: true
|
|
43
|
-
});
|
|
44
|
-
exports["default"] = void 0;
|
|
45
41
|
/**
|
|
46
42
|
* determine a string type
|
|
47
43
|
* @param str
|
|
48
44
|
* @returns {boolean}
|
|
49
45
|
*/
|
|
46
|
+
var isString = (str => typeof str === 'string' && str.constructor === String);
|
|
50
47
|
|
|
51
|
-
var _default = function _default(str) {
|
|
52
|
-
return typeof str === 'string' && str.constructor === String;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
exports["default"] = _default;
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
var isString$1 = unwrapExports(isString);
|
|
59
|
-
|
|
60
|
-
var isPromise = createCommonjsModule(function (module, exports) {
|
|
61
|
-
|
|
62
|
-
Object.defineProperty(exports, "__esModule", {
|
|
63
|
-
value: true
|
|
64
|
-
});
|
|
65
|
-
exports["default"] = void 0;
|
|
66
48
|
/**
|
|
67
49
|
* determine a promise type
|
|
68
50
|
* @param promise
|
|
69
51
|
* @returns {boolean}
|
|
70
52
|
*/
|
|
53
|
+
var isPromise = (promise => Object.prototype.toString.call(promise).slice(8, -1) === 'Promise');
|
|
71
54
|
|
|
72
|
-
var _default = function _default(promise) {
|
|
73
|
-
return Object.prototype.toString.call(promise).slice(8, -1) === 'Promise';
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
exports["default"] = _default;
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
unwrapExports(isPromise);
|
|
80
|
-
|
|
81
|
-
var functionToPromise = createCommonjsModule(function (module, exports) {
|
|
82
|
-
|
|
83
|
-
Object.defineProperty(exports, "__esModule", {
|
|
84
|
-
value: true
|
|
85
|
-
});
|
|
86
|
-
exports["default"] = void 0;
|
|
87
|
-
|
|
88
|
-
var _isPromise = _interopRequireDefault(isPromise);
|
|
89
|
-
|
|
90
|
-
function _interopRequireDefault(obj) {
|
|
91
|
-
return obj && obj.__esModule ? obj : {
|
|
92
|
-
"default": obj
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
55
|
/**
|
|
96
56
|
* function to promise
|
|
97
57
|
* @param normalFunction
|
|
@@ -99,26 +59,20 @@
|
|
|
99
59
|
* @returns {Promise<any>}
|
|
100
60
|
*/
|
|
101
61
|
|
|
102
|
-
|
|
103
|
-
var _default = function _default(normalFunction) {
|
|
62
|
+
var functionToPromise = (function (normalFunction) {
|
|
104
63
|
var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
105
64
|
|
|
106
|
-
if ((
|
|
65
|
+
if (isPromise(normalFunction)) {
|
|
107
66
|
return normalFunction;
|
|
108
67
|
} // eslint-disable-next-line no-undef
|
|
109
68
|
|
|
110
69
|
|
|
111
|
-
return new Promise(
|
|
70
|
+
return new Promise(resolve => {
|
|
112
71
|
normalFunction();
|
|
113
72
|
setTimeout(resolve, timeout);
|
|
114
73
|
});
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
exports["default"] = _default;
|
|
118
74
|
});
|
|
119
75
|
|
|
120
|
-
var functionToPromise$1 = unwrapExports(functionToPromise);
|
|
121
|
-
|
|
122
76
|
function styleInject(css, ref) {
|
|
123
77
|
if (ref === void 0) ref = {};
|
|
124
78
|
var insertAt = ref.insertAt;
|
|
@@ -148,8 +102,8 @@
|
|
|
148
102
|
}
|
|
149
103
|
}
|
|
150
104
|
|
|
151
|
-
var css_248z = ".
|
|
152
|
-
var _style = {"canvas":"
|
|
105
|
+
var css_248z = ".WJ3NAvwFY9,.ZgIIHVSSYI,.kAA8SjbHe2,.tR2-0dd-e1{height:100%;left:0;position:absolute;top:0;width:100%;z-index:1}.ZgIIHVSSYI{-ms-flex-pack:center;-ms-flex-align:center;-webkit-align-items:center;align-items:center;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-justify-content:center;justify-content:center}.WJ3NAvwFY9,.tR2-0dd-e1{display:block}.tR2-0dd-e1.OueN4AU4CJ{display:none}.ZgIIHVSSYI,.kAA8SjbHe2{-webkit-tap-highlight-color:rgba(255,0,0,0);cursor:pointer;opacity:.7}.OueN4AU4CJ.ZgIIHVSSYI,.OueN4AU4CJ.kAA8SjbHe2{display:none}.ZgIIHVSSYI{z-index:10}.ZgIIHVSSYI>svg{fill:#fff;height:12vw;max-height:60px;max-width:60px;width:12vw}.kAA8SjbHe2{-ms-flex-pack:end;-ms-flex-align:end;-webkit-align-items:flex-end;align-items:flex-end;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-justify-content:flex-end;justify-content:flex-end;z-index:10}.kAA8SjbHe2>svg{fill:#fff;height:9vw;margin:0 15px 15px 0;max-height:40px;max-width:40px;width:9vw}";
|
|
106
|
+
var _style = {"canvas":"WJ3NAvwFY9","poster":"tR2-0dd-e1","playButton":"ZgIIHVSSYI","unmuteButton":"kAA8SjbHe2","hidden":"OueN4AU4CJ"};
|
|
153
107
|
styleInject(css_248z);
|
|
154
108
|
|
|
155
109
|
/**
|
|
@@ -217,7 +171,7 @@
|
|
|
217
171
|
this.player = null; // Setup canvas and play button
|
|
218
172
|
|
|
219
173
|
this.els = {
|
|
220
|
-
wrapper: isString
|
|
174
|
+
wrapper: isString(wrapper) ? document.querySelector(wrapper) : wrapper,
|
|
221
175
|
canvas: null,
|
|
222
176
|
playButton: document.createElement('div'),
|
|
223
177
|
unmuteButton: null,
|
|
@@ -238,7 +192,7 @@
|
|
|
238
192
|
|
|
239
193
|
_proto.initCanvas = function initCanvas() {
|
|
240
194
|
if (this.options.canvas) {
|
|
241
|
-
this.els.canvas = isString
|
|
195
|
+
this.els.canvas = isString(this.options.canvas) ? document.querySelector(this.options.canvas) : this.options.canvas;
|
|
242
196
|
} else {
|
|
243
197
|
this.els.canvas = document.createElement('canvas');
|
|
244
198
|
this.els.canvas.classList.add(_style.canvas);
|
|
@@ -365,7 +319,7 @@
|
|
|
365
319
|
}
|
|
366
320
|
|
|
367
321
|
return Promise.resolve().then(function () {
|
|
368
|
-
return functionToPromise
|
|
322
|
+
return functionToPromise(function () {
|
|
369
323
|
_this2.els.wrapper.style.width = destination.width + "px";
|
|
370
324
|
_this2.els.wrapper.style.height = destination.height + "px";
|
|
371
325
|
});
|
|
@@ -807,10 +761,10 @@
|
|
|
807
761
|
|
|
808
762
|
if (this.index === this.byteLength << 3 || sizeNeeded > available + bytePos // emergency evac
|
|
809
763
|
) {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
764
|
+
this.byteLength = 0;
|
|
765
|
+
this.index = 0;
|
|
766
|
+
return;
|
|
767
|
+
} else if (bytePos === 0) {
|
|
814
768
|
// Nothing read yet - we can't evict anything
|
|
815
769
|
return;
|
|
816
770
|
} // Some browsers don't support copyWithin() yet - we may have to do
|
|
@@ -992,16 +946,16 @@
|
|
|
992
946
|
|
|
993
947
|
var end = (this.bits.index >> 3) + 187; // eslint-disable-next-line no-unused-vars
|
|
994
948
|
|
|
995
|
-
|
|
949
|
+
this.bits.read(1);
|
|
996
950
|
var payloadStart = this.bits.read(1); // eslint-disable-next-line no-unused-vars
|
|
997
951
|
|
|
998
|
-
|
|
952
|
+
this.bits.read(1);
|
|
999
953
|
var pid = this.bits.read(13); // eslint-disable-next-line no-unused-vars
|
|
1000
954
|
|
|
1001
|
-
|
|
955
|
+
this.bits.read(2);
|
|
1002
956
|
var adaptationField = this.bits.read(2); // eslint-disable-next-line no-unused-vars
|
|
1003
957
|
|
|
1004
|
-
|
|
958
|
+
this.bits.read(4); // If this is the start of a new payload; signal the end of the previous
|
|
1005
959
|
// frame, if we didn't do so already.
|
|
1006
960
|
|
|
1007
961
|
var streamId = this.pidsToStreamIds[pid];
|
|
@@ -3106,7 +3060,7 @@
|
|
|
3106
3060
|
|
|
3107
3061
|
var padding = this.bits.read(1); // eslint-disable-next-line no-unused-vars
|
|
3108
3062
|
|
|
3109
|
-
|
|
3063
|
+
this.bits.read(1);
|
|
3110
3064
|
var mode = this.bits.read(2); // Parse the mode_extension, set up the stereo bound
|
|
3111
3065
|
|
|
3112
3066
|
var bound = 0;
|
|
@@ -4507,7 +4461,7 @@
|
|
|
4507
4461
|
|
|
4508
4462
|
next = 9; // eslint-disable-next-line no-unused-vars
|
|
4509
4463
|
|
|
4510
|
-
|
|
4464
|
+
readVarUint();
|
|
4511
4465
|
|
|
4512
4466
|
if (!matchNextBytes([6, 'd', 'y', 'l', 'i', 'n', 'k'])) {
|
|
4513
4467
|
console.warn('JSMpeg: No dylink section found in WASM');
|
|
@@ -4863,8 +4817,8 @@
|
|
|
4863
4817
|
} // If there's not enough data and the source is not completed, we have
|
|
4864
4818
|
// just stalled.
|
|
4865
4819
|
else if (notEnoughData && this.options.onStalled) {
|
|
4866
|
-
|
|
4867
|
-
|
|
4820
|
+
this.options.onStalled(this);
|
|
4821
|
+
}
|
|
4868
4822
|
};
|
|
4869
4823
|
|
|
4870
4824
|
return Player;
|
|
@@ -5045,4 +4999,4 @@
|
|
|
5045
4999
|
|
|
5046
5000
|
return JSMpeg;
|
|
5047
5001
|
|
|
5048
|
-
}))
|
|
5002
|
+
}));
|