neoplayer 1.0.0 → 1.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.
@@ -2278,6 +2278,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
2278
2278
  AxiosHeaders$1.accessor([
2279
2279
  'Content-Type',
2280
2280
  'Content-Length',
2281
+ 'Content-Encoding',
2281
2282
  'Accept',
2282
2283
  'Accept-Encoding',
2283
2284
  'User-Agent',
@@ -3034,8 +3035,13 @@ class InterceptorManager {
3034
3035
  const handler = {
3035
3036
  fulfilled,
3036
3037
  rejected,
3037
- synchronous: options ? options.synchronous : false,
3038
- runWhen: options ? options.runWhen : null,
3038
+ // Options from a class or template object are read as usual; a value
3039
+ // only inherited from Object.prototype is ignored.
3040
+ synchronous:
3041
+ options && utils$1.hasOwnInPrototypeChain(options, 'synchronous')
3042
+ ? options.synchronous
3043
+ : false,
3044
+ runWhen: options && utils$1.hasOwnInPrototypeChain(options, 'runWhen') ? options.runWhen : null,
3039
3045
  };
3040
3046
  const internals = this[$internals];
3041
3047
 
@@ -3932,6 +3938,14 @@ function combineURLs(baseURL, relativeURL) {
3932
3938
  end--;
3933
3939
  }
3934
3940
 
3941
+ if (end === 0) {
3942
+ // A base made only of slashes points at the root of the current origin.
3943
+ // Drop leading slashes, backslashes, tabs and newlines from the relative
3944
+ // URL as well: URL parsers ignore tabs and newlines and treat '\\' as '/',
3945
+ // so leaving them would turn the result into a protocol-relative URL.
3946
+ return '/' + relativeURL.replace(/^[/\\\t\n\r]+/, '');
3947
+ }
3948
+
3935
3949
  return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
3936
3950
  }
3937
3951
 
@@ -4928,6 +4942,11 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
4928
4942
  }
4929
4943
  controller.enqueue(new Uint8Array(value));
4930
4944
  } catch (err) {
4945
+ // A progress callback can fail while the source iterator is suspended at
4946
+ // a yield. Close it without delaying or replacing the original error.
4947
+ // This return() call has no cancellation reason, so the source's cancel()
4948
+ // receives undefined, as it does from the cancel() hook below.
4949
+ iterator.return().catch(() => {});
4931
4950
  _onFinish(err);
4932
4951
  throw err;
4933
4952
  }
@@ -5246,7 +5265,7 @@ function estimateDataURLDecodedBytes(url) {
5246
5265
  );
5247
5266
  }
5248
5267
 
5249
- const VERSION$1 = "1.21.1";
5268
+ const VERSION$1 = "1.22.0";
5250
5269
 
5251
5270
  const DEFAULT_CHUNK_SIZE = 64 * 1024;
5252
5271
 
@@ -5301,6 +5320,45 @@ const test = (fn, ...args) => {
5301
5320
  }
5302
5321
  };
5303
5322
 
5323
+ // Marks a probe body's cancellation result as handled. Reads `then` once and
5324
+ // does not go through the global Promise or `Promise.prototype.catch`, so a
5325
+ // rejected cancellation from a custom body cannot surface as an unhandled
5326
+ // rejection.
5327
+ const ignoreRejection = (result) => {
5328
+ try {
5329
+ if (result !== null && (typeof result === 'object' || typeof result === 'function')) {
5330
+ const then = result.then;
5331
+
5332
+ if (isFunction(then)) {
5333
+ then.call(result, undefined, utils$1.noop);
5334
+ }
5335
+ }
5336
+ } catch (e) {
5337
+ // Ignored: the cancellation has already been requested.
5338
+ }
5339
+ };
5340
+
5341
+ // On Node.js 22 and older, the body of the throwaway `new Response('')` used by
5342
+ // the response-stream probe leaves its stream's internal closed promise pending
5343
+ // until the stream is cancelled, which async-leak detectors report for every
5344
+ // realm that loads axios. This cleanup runs in `finally`, whether the check
5345
+ // returned or threw, and is best-effort so it never affects the probe result.
5346
+ const cancelProbeBody = (body) => {
5347
+ if (body == null) {
5348
+ return;
5349
+ }
5350
+
5351
+ try {
5352
+ const cancel = body.cancel;
5353
+
5354
+ if (isFunction(cancel)) {
5355
+ ignoreRejection(cancel.call(body));
5356
+ }
5357
+ } catch (e) {
5358
+ // Ignored: an uncancellable probe body is still a valid probe result.
5359
+ }
5360
+ };
5361
+
5304
5362
  const maybeWithAuthCredentials = (url) => {
5305
5363
  const protocolIndex = url.indexOf('://');
5306
5364
  let urlToCheck = url;
@@ -5366,7 +5424,7 @@ const factory = (env) => {
5366
5424
  const hasContentType = request.headers.has('Content-Type');
5367
5425
 
5368
5426
  if (request.body != null) {
5369
- request.body.cancel();
5427
+ ignoreRejection(request.body.cancel());
5370
5428
  }
5371
5429
 
5372
5430
  return duplexAccessed && !hasContentType;
@@ -5375,7 +5433,15 @@ const factory = (env) => {
5375
5433
  const supportsResponseStream =
5376
5434
  isResponseSupported &&
5377
5435
  isReadableStreamSupported &&
5378
- test(() => utils$1.isReadableStream(new Response('').body));
5436
+ test(() => {
5437
+ const probeBody = new Response('').body;
5438
+
5439
+ try {
5440
+ return utils$1.isReadableStream(probeBody);
5441
+ } finally {
5442
+ cancelProbeBody(probeBody);
5443
+ }
5444
+ });
5379
5445
 
5380
5446
  // Some runtimes reject every explicit cache mode. Use own defaults for both
5381
5447
  // probes so unrelated polluted options cannot affect cache-mode detection.
@@ -5947,6 +6013,28 @@ const factory = (env) => {
5947
6013
 
5948
6014
  const seedCache = new Map();
5949
6015
 
6016
+ // Every adapter the factory has created. The adapter is cached per
6017
+ // environment, so one created for another environment, such as by
6018
+ // `axios.getAdapter('fetch')` without a config, is still recognized.
6019
+ const createdAdapters = new WeakSet();
6020
+
6021
+ const createAdapter = (env) => {
6022
+ const adapter = factory(env);
6023
+
6024
+ adapter && createdAdapters.add(adapter);
6025
+
6026
+ return adapter;
6027
+ };
6028
+
6029
+ /**
6030
+ * Check whether a function was created by the fetch adapter factory.
6031
+ *
6032
+ * @param {*} adapter The value to check
6033
+ *
6034
+ * @returns {boolean} `true` for a built-in fetch adapter
6035
+ */
6036
+ const isFetchAdapter = (adapter) => createdAdapters.has(adapter);
6037
+
5950
6038
  const getFetch = (config) => {
5951
6039
  const env = Object.create(null);
5952
6040
  const configuredEnv = config && utils$1.hasOwnProp(config, 'env') && config.env;
@@ -5968,7 +6056,7 @@ const getFetch = (config) => {
5968
6056
  seed = seeds[i];
5969
6057
  target = map.get(seed);
5970
6058
 
5971
- target === undefined && map.set(seed, (target = i ? new Map() : factory(env)));
6059
+ target === undefined && map.set(seed, (target = i ? new Map() : createAdapter(env)));
5972
6060
 
5973
6061
  map = target;
5974
6062
  }
@@ -6088,6 +6176,21 @@ function getAdapter$1(adapters, config) {
6088
6176
  return adapter;
6089
6177
  }
6090
6178
 
6179
+ /**
6180
+ * Check whether a resolved adapter function is one of the built-in adapters.
6181
+ *
6182
+ * @param {Function} adapter The adapter resolved by `getAdapter`
6183
+ * @returns {boolean} `true` for the built-in `xhr`, `http` or `fetch` adapter
6184
+ */
6185
+ function isBuiltinAdapter(adapter) {
6186
+ return (
6187
+ !!adapter &&
6188
+ (adapter === knownAdapters.xhr ||
6189
+ adapter === knownAdapters.http ||
6190
+ isFetchAdapter(adapter))
6191
+ );
6192
+ }
6193
+
6091
6194
  /**
6092
6195
  * Exports Axios adapters and utility to resolve an adapter
6093
6196
  */
@@ -6098,6 +6201,12 @@ var adapters = {
6098
6201
  */
6099
6202
  getAdapter: getAdapter$1,
6100
6203
 
6204
+ /**
6205
+ * Check whether a resolved adapter is a built-in one.
6206
+ * @type {Function}
6207
+ */
6208
+ isBuiltinAdapter,
6209
+
6101
6210
  /**
6102
6211
  * Exposes all known adapters
6103
6212
  * @type {Object<string, Function|Object>}
@@ -6105,6 +6214,63 @@ var adapters = {
6105
6214
  adapters: knownAdapters,
6106
6215
  };
6107
6216
 
6217
+ /**
6218
+ * Reject a `null` or `undefined` url that a built-in adapter would send
6219
+ * somewhere the caller did not choose.
6220
+ *
6221
+ * With params, the nullish url becomes a query-only url such as `?foo=bar`,
6222
+ * which a browser resolves against the current page. Without params, XHR
6223
+ * requests `./null` or `./undefined` and the Node adapter throws a native
6224
+ * `TypeError`.
6225
+ *
6226
+ * The request still has a destination when `baseURL` is set, or when the Node
6227
+ * HTTP adapter is given a `socketPath`. A caller-supplied adapter handles its
6228
+ * own destination and is not checked.
6229
+ *
6230
+ * `dispatchRequest` and `Axios#getUri` both call this, so `getUri` rejects
6231
+ * exactly the configs that a request would reject. Request interceptors are
6232
+ * not run by `getUri`, so a url that an interceptor would supply is still
6233
+ * missing there. Keep this out of `buildURL` and `buildFullPath`: they only
6234
+ * format urls and have other callers.
6235
+ *
6236
+ * @param {Object} config The merged request config
6237
+ * @param {Function} resolveAdapter Returns the adapter that handles the
6238
+ * request. Called only for a nullish url without `baseURL`, so a usable url
6239
+ * never depends on adapter resolution.
6240
+ *
6241
+ * @returns {void}
6242
+ */
6243
+ function assertValidRequestUrl(config, resolveAdapter) {
6244
+ const url = utils$1.getSafeProp(config, 'url');
6245
+
6246
+ if (url !== null && url !== undefined) {
6247
+ return;
6248
+ }
6249
+
6250
+ if (utils$1.getSafeProp(config, 'baseURL')) {
6251
+ return;
6252
+ }
6253
+
6254
+ const adapter = resolveAdapter();
6255
+
6256
+ // Only the Node HTTP adapter reads socketPath; XHR and fetch ignore it.
6257
+ const httpAdapter = adapters.adapters.http;
6258
+
6259
+ if (httpAdapter && adapter === httpAdapter && utils$1.getSafeProp(config, 'socketPath')) {
6260
+ return;
6261
+ }
6262
+
6263
+ if (!adapters.isBuiltinAdapter(adapter)) {
6264
+ return;
6265
+ }
6266
+
6267
+ throw new AxiosError$1(
6268
+ `Invalid URL: url cannot be ${url === null ? 'null' : 'undefined'} when baseURL is not set`,
6269
+ AxiosError$1.ERR_INVALID_URL,
6270
+ config
6271
+ );
6272
+ }
6273
+
6108
6274
  /**
6109
6275
  * Throws a `CanceledError` if cancellation has been requested.
6110
6276
  *
@@ -6179,6 +6345,9 @@ function dispatchRequest(_config) {
6179
6345
 
6180
6346
  const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
6181
6347
 
6348
+ // Runs after resolution so a custom adapter is recognized in any form.
6349
+ assertValidRequestUrl(config, () => adapter);
6350
+
6182
6351
  const now = resolveClock();
6183
6352
  const start = now();
6184
6353
 
@@ -6634,6 +6803,9 @@ let Axios$1 = class Axios {
6634
6803
 
6635
6804
  getUri(config) {
6636
6805
  config = mergeConfig$1(this.defaults, config);
6806
+ assertValidRequestUrl(config, () =>
6807
+ adapters.getAdapter(config.adapter || defaults.adapter, config)
6808
+ );
6637
6809
  const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls, config);
6638
6810
  return buildURL(fullPath, config.params, config.paramsSerializer);
6639
6811
  }
@@ -7070,7 +7242,7 @@ const defaultApiBackend = {
7070
7242
  },
7071
7243
  };
7072
7244
 
7073
- /* global "1.0.0" */
7245
+ /* global "1.1.0" */
7074
7246
  function handleOption(options) {
7075
7247
  var _a, _b, _c;
7076
7248
  const defaultOption = {
@@ -7144,7 +7316,7 @@ function handleOption(options) {
7144
7316
  link: 'https://github.com/Fluxonide',
7145
7317
  },
7146
7318
  {
7147
- text: `NeoPlayer v${"1.0.0"}`,
7319
+ text: `NeoPlayer v${"1.1.0"}`,
7148
7320
  link: 'https://github.com/Fluxonide/NeoPlayer',
7149
7321
  },
7150
7322
  ]);
@@ -7689,14 +7861,6 @@ function tplPlayer(data) {
7689
7861
  : '';
7690
7862
  const infoDanmakuHtml = options.danmaku
7691
7863
  ? `
7692
- <div class="dplayer-info-panel-item dplayer-info-panel-item-danmaku-id">
7693
- <span class="dplayer-info-panel-item-title">Danmaku id</span>
7694
- <span class="dplayer-info-panel-item-data"></span>
7695
- </div>
7696
- <div class="dplayer-info-panel-item dplayer-info-panel-item-danmaku-api">
7697
- <span class="dplayer-info-panel-item-title">Danmaku api</span>
7698
- <span class="dplayer-info-panel-item-data"></span>
7699
- </div>
7700
7864
  <div class="dplayer-info-panel-item dplayer-info-panel-item-danmaku-amount">
7701
7865
  <span class="dplayer-info-panel-item-title">Danmaku amount</span>
7702
7866
  <span class="dplayer-info-panel-item-data"></span>
@@ -7830,29 +7994,56 @@ function tplPlayer(data) {
7830
7994
  </div>
7831
7995
  </div>
7832
7996
  <div class="dplayer-info-panel dplayer-info-panel-hide">
7833
- <div class="dplayer-info-panel-close">[x]</div>
7997
+ <div class="dplayer-info-panel-actions">
7998
+ <span class="dplayer-info-panel-copy" title="Copy stats">[Copy]</span>
7999
+ <span class="dplayer-info-panel-close" title="Close">[x]</span>
8000
+ </div>
7834
8001
  <div class="dplayer-info-panel-item dplayer-info-panel-item-version">
7835
8002
  <span class="dplayer-info-panel-item-title">Player version</span>
7836
8003
  <span class="dplayer-info-panel-item-data"></span>
7837
8004
  </div>
8005
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-url">
8006
+ <span class="dplayer-info-panel-item-title">Video url</span>
8007
+ <span class="dplayer-info-panel-item-data"></span>
8008
+ </div>
8009
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-resolution">
8010
+ <span class="dplayer-info-panel-item-title">Viewport / Res</span>
8011
+ <span class="dplayer-info-panel-item-data"></span>
8012
+ </div>
7838
8013
  <div class="dplayer-info-panel-item dplayer-info-panel-item-fps">
7839
- <span class="dplayer-info-panel-item-title">Player FPS</span>
8014
+ <span class="dplayer-info-panel-item-title">Video FPS</span>
7840
8015
  <span class="dplayer-info-panel-item-data"></span>
7841
8016
  </div>
7842
- <div class="dplayer-info-panel-item dplayer-info-panel-item-type">
7843
- <span class="dplayer-info-panel-item-title">Video type</span>
8017
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-codecs">
8018
+ <span class="dplayer-info-panel-item-title">Codecs</span>
7844
8019
  <span class="dplayer-info-panel-item-data"></span>
7845
8020
  </div>
7846
- <div class="dplayer-info-panel-item dplayer-info-panel-item-url">
7847
- <span class="dplayer-info-panel-item-title">Video url</span>
8021
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-bitrate">
8022
+ <span class="dplayer-info-panel-item-title">Bitrate</span>
7848
8023
  <span class="dplayer-info-panel-item-data"></span>
7849
8024
  </div>
7850
- <div class="dplayer-info-panel-item dplayer-info-panel-item-resolution">
7851
- <span class="dplayer-info-panel-item-title">Video resolution</span>
8025
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-connection">
8026
+ <span class="dplayer-info-panel-item-title">Connection</span>
7852
8027
  <span class="dplayer-info-panel-item-data"></span>
7853
8028
  </div>
7854
8029
  <div class="dplayer-info-panel-item dplayer-info-panel-item-duration">
7855
- <span class="dplayer-info-panel-item-title">Video duration</span>
8030
+ <span class="dplayer-info-panel-item-title">Time / Duration</span>
8031
+ <span class="dplayer-info-panel-item-data"></span>
8032
+ </div>
8033
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-frames">
8034
+ <span class="dplayer-info-panel-item-title">Dropped frames</span>
8035
+ <span class="dplayer-info-panel-item-data"></span>
8036
+ </div>
8037
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-buffer">
8038
+ <span class="dplayer-info-panel-item-title">Buffer health</span>
8039
+ <span class="dplayer-info-panel-item-data"></span>
8040
+ </div>
8041
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-playback">
8042
+ <span class="dplayer-info-panel-item-title">Playback</span>
8043
+ <span class="dplayer-info-panel-item-data"></span>
8044
+ </div>
8045
+ <div class="dplayer-info-panel-item dplayer-info-panel-item-tracks">
8046
+ <span class="dplayer-info-panel-item-title">Tracks</span>
7856
8047
  <span class="dplayer-info-panel-item-data"></span>
7857
8048
  </div>
7858
8049
  ${infoDanmakuHtml}
@@ -7968,14 +8159,19 @@ class Template {
7968
8159
  this.noticeList = q('.dplayer-notice-list');
7969
8160
  this.infoPanel = q('.dplayer-info-panel');
7970
8161
  this.infoPanelClose = q('.dplayer-info-panel-close');
8162
+ this.infoPanelCopy = q('.dplayer-info-panel-copy');
7971
8163
  this.infoVersion = q('.dplayer-info-panel-item-version .dplayer-info-panel-item-data');
7972
8164
  this.infoFPS = q('.dplayer-info-panel-item-fps .dplayer-info-panel-item-data');
7973
- this.infoType = q('.dplayer-info-panel-item-type .dplayer-info-panel-item-data');
7974
8165
  this.infoUrl = q('.dplayer-info-panel-item-url .dplayer-info-panel-item-data');
8166
+ this.infoCodecs = q('.dplayer-info-panel-item-codecs .dplayer-info-panel-item-data');
8167
+ this.infoBitrate = q('.dplayer-info-panel-item-bitrate .dplayer-info-panel-item-data');
8168
+ this.infoConnection = q('.dplayer-info-panel-item-connection .dplayer-info-panel-item-data');
7975
8169
  this.infoResolution = q('.dplayer-info-panel-item-resolution .dplayer-info-panel-item-data');
7976
8170
  this.infoDuration = q('.dplayer-info-panel-item-duration .dplayer-info-panel-item-data');
7977
- this.infoDanmakuId = q('.dplayer-info-panel-item-danmaku-id .dplayer-info-panel-item-data');
7978
- this.infoDanmakuApi = q('.dplayer-info-panel-item-danmaku-api .dplayer-info-panel-item-data');
8171
+ this.infoFrames = q('.dplayer-info-panel-item-frames .dplayer-info-panel-item-data');
8172
+ this.infoBuffer = q('.dplayer-info-panel-item-buffer .dplayer-info-panel-item-data');
8173
+ this.infoPlayback = q('.dplayer-info-panel-item-playback .dplayer-info-panel-item-data');
8174
+ this.infoTracks = q('.dplayer-info-panel-item-tracks .dplayer-info-panel-item-data');
7979
8175
  this.infoDanmakuAmount = q('.dplayer-info-panel-item-danmaku-amount .dplayer-info-panel-item-data');
7980
8176
  }
7981
8177
  /** Create a notice element */
@@ -10136,7 +10332,12 @@ class ContextMenu {
10136
10332
 
10137
10333
  class InfoPanel {
10138
10334
  constructor(player) {
10139
- this.beginTime = 0;
10335
+ this.lastDecodedBytes = 0;
10336
+ this.lastBitrateTime = 0;
10337
+ this.lastBitrateBps = 0;
10338
+ this.lastTotalFrames = 0;
10339
+ this.lastFpsTime = 0;
10340
+ this.lastVideoFps = 0;
10140
10341
  this.container = player.template.infoPanel;
10141
10342
  this.template = player.template;
10142
10343
  this.video = player.video;
@@ -10144,17 +10345,17 @@ class InfoPanel {
10144
10345
  this.template.infoPanelClose.addEventListener('click', () => {
10145
10346
  this.hide();
10146
10347
  });
10348
+ this.template.infoPanelCopy.addEventListener('click', () => {
10349
+ this.copyStats();
10350
+ });
10147
10351
  }
10148
10352
  show() {
10149
- this.beginTime = Date.now();
10150
10353
  this.update();
10151
10354
  this.player.timer.enable('info');
10152
- this.player.timer.enable('fps');
10153
10355
  this.container.classList.remove('dplayer-info-panel-hide');
10154
10356
  }
10155
10357
  hide() {
10156
10358
  this.player.timer.disable('info');
10157
- this.player.timer.disable('fps');
10158
10359
  this.container.classList.add('dplayer-info-panel-hide');
10159
10360
  }
10160
10361
  triggle() {
@@ -10167,23 +10368,304 @@ class InfoPanel {
10167
10368
  }
10168
10369
  update() {
10169
10370
  var _a, _b;
10170
- this.template.infoVersion.innerHTML = `v${"1.0.0"} ${"55672b9"}`;
10171
- this.template.infoType.innerHTML = this.player.type;
10172
- this.template.infoUrl.innerHTML = this.player.options.video.url;
10173
- this.template.infoResolution.innerHTML = `${this.video.videoWidth} x ${this.video.videoHeight}`;
10174
- this.template.infoDuration.innerHTML = String(this.video.duration);
10371
+ const video = this.video;
10372
+ const url = this.player.options.video.url;
10373
+ const dpr = window.devicePixelRatio > 1 ? `@${window.devicePixelRatio.toFixed(1).replace(/\.0$/, '')}x` : '';
10374
+ this.template.infoVersion.textContent = `v${"1.1.0"} ${"af9d9ca"}`;
10375
+ this.template.infoUrl.textContent = url;
10376
+ this.template.infoUrl.title = url;
10377
+ this.template.infoResolution.textContent = `${video.clientWidth}x${video.clientHeight}${dpr} / ${video.videoWidth}x${video.videoHeight}`;
10378
+ this.template.infoFPS.textContent = this.formatVideoFPS();
10379
+ this.template.infoCodecs.textContent = this.formatCodecs(url);
10380
+ this.template.infoBitrate.textContent = this.formatBitrate();
10381
+ this.template.infoConnection.textContent = this.formatConnection();
10382
+ this.template.infoDuration.textContent = this.formatTimeDuration(video.currentTime, video.duration);
10383
+ this.template.infoFrames.textContent = this.formatFrameStats();
10384
+ this.template.infoBuffer.textContent = this.formatBufferHealth();
10385
+ const vol = video.muted ? 'Muted' : `${Math.round(video.volume * 100)}%`;
10386
+ const state = video.paused ? ' (Paused)' : '';
10387
+ this.template.infoPlayback.textContent = `${video.playbackRate}x | Vol ${vol}${state}`;
10388
+ this.template.infoTracks.textContent = this.formatTracks();
10175
10389
  if (this.player.options.danmaku) {
10176
- this.template.infoDanmakuId.innerHTML = this.player.options.danmaku.id;
10177
- this.template.infoDanmakuApi.innerHTML = this.player.options.danmaku.api;
10178
- this.template.infoDanmakuAmount.innerHTML = String((_b = (_a = this.player.danmaku) === null || _a === void 0 ? void 0 : _a.dan.length) !== null && _b !== void 0 ? _b : 0);
10390
+ this.template.infoDanmakuAmount.textContent = String((_b = (_a = this.player.danmaku) === null || _a === void 0 ? void 0 : _a.dan.length) !== null && _b !== void 0 ? _b : 0);
10391
+ }
10392
+ }
10393
+ fps(_value) {
10394
+ // Video FPS is updated via formatVideoFPS() on the 1s info tick.
10395
+ }
10396
+ copyStats() {
10397
+ var _a;
10398
+ const items = this.container.querySelectorAll('.dplayer-info-panel-item');
10399
+ const lines = [];
10400
+ items.forEach((item) => {
10401
+ var _a, _b, _c, _d;
10402
+ const title = (_b = (_a = item.querySelector('.dplayer-info-panel-item-title')) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
10403
+ const data = (_d = (_c = item.querySelector('.dplayer-info-panel-item-data')) === null || _c === void 0 ? void 0 : _c.textContent) === null || _d === void 0 ? void 0 : _d.trim();
10404
+ if (title && data) {
10405
+ lines.push(`${title}: ${data}`);
10406
+ }
10407
+ });
10408
+ const text = lines.join('\n');
10409
+ const flashCopied = () => {
10410
+ this.template.infoPanelCopy.textContent = '[Copied]';
10411
+ setTimeout(() => {
10412
+ this.template.infoPanelCopy.textContent = '[Copy]';
10413
+ }, 1500);
10414
+ };
10415
+ if ((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText) {
10416
+ navigator.clipboard.writeText(text).then(flashCopied).catch(() => { });
10179
10417
  }
10180
10418
  }
10181
- fps(value) {
10182
- this.template.infoFPS.innerHTML = value.toFixed(1);
10419
+ formatVideoFPS() {
10420
+ var _a, _b, _c, _d;
10421
+ const hls = this.player.plugins.hls;
10422
+ if ((hls === null || hls === void 0 ? void 0 : hls.levels) && hls.levels.length > 0) {
10423
+ const idx = hls.currentLevel !== undefined && hls.currentLevel >= 0 ? hls.currentLevel : ((_a = hls.loadLevel) !== null && _a !== void 0 ? _a : 0);
10424
+ const rate = (_c = (_b = hls.levels[idx]) === null || _b === void 0 ? void 0 : _b.attrs) === null || _c === void 0 ? void 0 : _c['FRAME-RATE'];
10425
+ if (rate)
10426
+ return `${Number(rate).toFixed(2).replace(/\.00$/, '')} fps`;
10427
+ }
10428
+ const flv = this.player.plugins.flvjs;
10429
+ if (((_d = flv === null || flv === void 0 ? void 0 : flv.mediaInfo) === null || _d === void 0 ? void 0 : _d.fps) && flv.mediaInfo.fps > 0) {
10430
+ return `${flv.mediaInfo.fps.toFixed(2).replace(/\.00$/, '')} fps`;
10431
+ }
10432
+ const totalFrames = this.getTotalVideoFrames();
10433
+ if (totalFrames !== null) {
10434
+ const now = Date.now();
10435
+ if (this.lastFpsTime > 0 && now > this.lastFpsTime && totalFrames >= this.lastTotalFrames) {
10436
+ const dt = (now - this.lastFpsTime) / 1000;
10437
+ const measured = (totalFrames - this.lastTotalFrames) / dt;
10438
+ if (measured > 0) {
10439
+ this.lastVideoFps = measured;
10440
+ }
10441
+ }
10442
+ this.lastTotalFrames = totalFrames;
10443
+ this.lastFpsTime = now;
10444
+ if (this.lastVideoFps > 0) {
10445
+ return `${this.lastVideoFps.toFixed(1)} fps (decoded)`;
10446
+ }
10447
+ }
10448
+ return 'N/A';
10449
+ }
10450
+ getTotalVideoFrames() {
10451
+ if (typeof this.video.getVideoPlaybackQuality === 'function') {
10452
+ return this.video.getVideoPlaybackQuality().totalVideoFrames;
10453
+ }
10454
+ const wk = this.video;
10455
+ return typeof wk.webkitDecodedFrameCount === 'number' ? wk.webkitDecodedFrameCount : null;
10456
+ }
10457
+ formatTracks() {
10458
+ const parts = [];
10459
+ const wk = this.video;
10460
+ if (wk.audioTracks && wk.audioTracks.length > 0) {
10461
+ let activeAudio = '';
10462
+ for (let i = 0; i < wk.audioTracks.length; i++) {
10463
+ const t = wk.audioTracks[i];
10464
+ if (t.enabled) {
10465
+ activeAudio = t.label || t.language || `#${i + 1}`;
10466
+ break;
10467
+ }
10468
+ }
10469
+ parts.push(`Audio: ${activeAudio || wk.audioTracks.length}`);
10470
+ }
10471
+ const textTracks = this.video.textTracks;
10472
+ if (textTracks && textTracks.length > 0) {
10473
+ let activeSub = 'Off';
10474
+ for (let i = 0; i < textTracks.length; i++) {
10475
+ const t = textTracks[i];
10476
+ if (t.mode === 'showing') {
10477
+ activeSub = t.label || t.language || 'On';
10478
+ break;
10479
+ }
10480
+ }
10481
+ parts.push(`Sub: ${activeSub}`);
10482
+ }
10483
+ else {
10484
+ parts.push('Sub: None');
10485
+ }
10486
+ return parts.join(' | ');
10487
+ }
10488
+ formatCodecs(url) {
10489
+ var _a, _b, _c;
10490
+ const hls = this.player.plugins.hls;
10491
+ if ((hls === null || hls === void 0 ? void 0 : hls.levels) && hls.levels.length > 0) {
10492
+ const idx = hls.currentLevel !== undefined && hls.currentLevel >= 0 ? hls.currentLevel : ((_a = hls.loadLevel) !== null && _a !== void 0 ? _a : 0);
10493
+ const level = hls.levels[idx];
10494
+ if (level) {
10495
+ const parts = [level.videoCodec, level.audioCodec].filter(Boolean);
10496
+ if (parts.length > 0)
10497
+ return parts.join(' / ');
10498
+ if (level.codecs)
10499
+ return level.codecs;
10500
+ }
10501
+ }
10502
+ const dash = this.player.plugins.dash;
10503
+ if (dash === null || dash === void 0 ? void 0 : dash.getCurrentTrackFor) {
10504
+ const vCodec = (_b = dash.getCurrentTrackFor('video')) === null || _b === void 0 ? void 0 : _b.codec;
10505
+ const aCodec = (_c = dash.getCurrentTrackFor('audio')) === null || _c === void 0 ? void 0 : _c.codec;
10506
+ const parts = [vCodec, aCodec].filter(Boolean);
10507
+ if (parts.length > 0)
10508
+ return parts.join(' / ');
10509
+ }
10510
+ const flv = this.player.plugins.flvjs;
10511
+ if (flv === null || flv === void 0 ? void 0 : flv.mediaInfo) {
10512
+ const parts = [flv.mediaInfo.videoCodec, flv.mediaInfo.audioCodec].filter(Boolean);
10513
+ if (parts.length > 0)
10514
+ return parts.join(' / ');
10515
+ if (flv.mediaInfo.mimeType)
10516
+ return flv.mediaInfo.mimeType;
10517
+ }
10518
+ const cleanUrl = (this.video.currentSrc || url).split(/[?#]/)[0].toLowerCase();
10519
+ const ext = cleanUrl.includes('.') ? cleanUrl.split('.').pop() : '';
10520
+ const mimeMap = {
10521
+ mp4: 'MP4 (video/mp4)',
10522
+ m4v: 'MP4 (video/mp4)',
10523
+ webm: 'WebM (video/webm)',
10524
+ ogv: 'Ogg (video/ogg)',
10525
+ ogg: 'Ogg (video/ogg)',
10526
+ mov: 'MOV (video/quicktime)',
10527
+ m3u8: 'HLS (application/vnd.apple.mpegurl)',
10528
+ mpd: 'DASH (application/dash+xml)',
10529
+ flv: 'FLV (video/x-flv)',
10530
+ };
10531
+ if (ext && mimeMap[ext]) {
10532
+ return `${mimeMap[ext]} · native`;
10533
+ }
10534
+ return 'Native (browser-managed)';
10535
+ }
10536
+ formatBitrate() {
10537
+ var _a, _b, _c, _d, _e, _f;
10538
+ const hls = this.player.plugins.hls;
10539
+ if ((hls === null || hls === void 0 ? void 0 : hls.levels) && hls.levels.length > 0) {
10540
+ const idx = hls.currentLevel !== undefined && hls.currentLevel >= 0 ? hls.currentLevel : ((_a = hls.loadLevel) !== null && _a !== void 0 ? _a : 0);
10541
+ const bitrate = (_b = hls.levels[idx]) === null || _b === void 0 ? void 0 : _b.bitrate;
10542
+ if (bitrate && bitrate > 0) {
10543
+ return this.formatBps(bitrate);
10544
+ }
10545
+ }
10546
+ const dash = this.player.plugins.dash;
10547
+ if ((dash === null || dash === void 0 ? void 0 : dash.getQualityFor) && dash.getBitrateInfoListFor) {
10548
+ const q = dash.getQualityFor('video');
10549
+ const list = dash.getBitrateInfoListFor('video');
10550
+ const bitrate = (_c = list === null || list === void 0 ? void 0 : list[q]) === null || _c === void 0 ? void 0 : _c.bitrate;
10551
+ if (bitrate && bitrate > 0) {
10552
+ return this.formatBps(bitrate);
10553
+ }
10554
+ }
10555
+ const flv = this.player.plugins.flvjs;
10556
+ if (flv === null || flv === void 0 ? void 0 : flv.mediaInfo) {
10557
+ const totalKbps = ((_d = flv.mediaInfo.videoDataRate) !== null && _d !== void 0 ? _d : 0) + ((_e = flv.mediaInfo.audioDataRate) !== null && _e !== void 0 ? _e : 0);
10558
+ if (totalKbps > 0) {
10559
+ return this.formatBps(totalKbps * 1000);
10560
+ }
10561
+ }
10562
+ const wk = this.video;
10563
+ if (typeof wk.webkitVideoDecodedByteCount === 'number') {
10564
+ const totalBytes = wk.webkitVideoDecodedByteCount + ((_f = wk.webkitAudioDecodedByteCount) !== null && _f !== void 0 ? _f : 0);
10565
+ const now = Date.now();
10566
+ if (this.lastBitrateTime > 0 && now > this.lastBitrateTime && totalBytes >= this.lastDecodedBytes) {
10567
+ const dt = (now - this.lastBitrateTime) / 1000;
10568
+ const bps = ((totalBytes - this.lastDecodedBytes) * 8) / dt;
10569
+ if (bps > 0) {
10570
+ this.lastBitrateBps = bps;
10571
+ }
10572
+ }
10573
+ this.lastDecodedBytes = totalBytes;
10574
+ this.lastBitrateTime = now;
10575
+ if (this.lastBitrateBps > 0) {
10576
+ return `${this.formatBps(this.lastBitrateBps)} (decoded)`;
10577
+ }
10578
+ }
10579
+ return 'N/A';
10580
+ }
10581
+ formatConnection() {
10582
+ var _a;
10583
+ const parts = [];
10584
+ const hls = this.player.plugins.hls;
10585
+ const dash = this.player.plugins.dash;
10586
+ const flv = this.player.plugins.flvjs;
10587
+ if ((hls === null || hls === void 0 ? void 0 : hls.bandwidthEstimate) && hls.bandwidthEstimate > 0) {
10588
+ parts.push(`${this.formatBps(hls.bandwidthEstimate)} est.`);
10589
+ }
10590
+ else if (dash === null || dash === void 0 ? void 0 : dash.getAverageThroughput) {
10591
+ const tp = dash.getAverageThroughput('video');
10592
+ if (tp > 0)
10593
+ parts.push(`${this.formatBps(tp * 1000)} est.`);
10594
+ }
10595
+ else if (((_a = flv === null || flv === void 0 ? void 0 : flv.statisticsInfo) === null || _a === void 0 ? void 0 : _a.speed) && flv.statisticsInfo.speed > 0) {
10596
+ parts.push(`${flv.statisticsInfo.speed.toFixed(1)} KB/s`);
10597
+ }
10598
+ const nav = navigator;
10599
+ if (nav.connection) {
10600
+ const net = [];
10601
+ if (typeof nav.connection.downlink === 'number' && nav.connection.downlink > 0) {
10602
+ net.push(`${nav.connection.downlink.toFixed(1)} Mbps`);
10603
+ }
10604
+ if (nav.connection.effectiveType) {
10605
+ net.push(nav.connection.effectiveType);
10606
+ }
10607
+ if (net.length > 0)
10608
+ parts.push(net.join(' · '));
10609
+ }
10610
+ return parts.length > 0 ? parts.join(' | ') : 'N/A';
10611
+ }
10612
+ formatBps(bps) {
10613
+ if (bps >= 1000000) {
10614
+ return `${(bps / 1000000).toFixed(2)} Mbps`;
10615
+ }
10616
+ return `${Math.round(bps / 1000)} kbps`;
10617
+ }
10618
+ formatTimeDuration(currentTime, duration) {
10619
+ const cur = utils$2.secondToTime(currentTime);
10620
+ if (duration === Infinity) {
10621
+ return `${cur} / Live`;
10622
+ }
10623
+ if (Number.isFinite(duration) && duration > 0) {
10624
+ return `${cur} / ${utils$2.secondToTime(duration)} (${duration.toFixed(1)}s)`;
10625
+ }
10626
+ return `${cur} / 00:00`;
10627
+ }
10628
+ formatFrameStats() {
10629
+ if (typeof this.video.getVideoPlaybackQuality === 'function') {
10630
+ const quality = this.video.getVideoPlaybackQuality();
10631
+ const dropped = quality.droppedVideoFrames;
10632
+ const total = quality.totalVideoFrames;
10633
+ if (total > 0) {
10634
+ const pct = ((dropped / total) * 100).toFixed(1);
10635
+ return `${dropped} / ${total} (${pct}%)`;
10636
+ }
10637
+ return `${dropped} / ${total}`;
10638
+ }
10639
+ const wk = this.video;
10640
+ if (typeof wk.webkitDroppedFrameCount === 'number' && typeof wk.webkitDecodedFrameCount === 'number') {
10641
+ const dropped = wk.webkitDroppedFrameCount;
10642
+ const total = wk.webkitDecodedFrameCount;
10643
+ const pct = total > 0 ? ((dropped / total) * 100).toFixed(1) : '0.0';
10644
+ return `${dropped} / ${total} (${pct}%)`;
10645
+ }
10646
+ return 'N/A';
10647
+ }
10648
+ formatBufferHealth() {
10649
+ const { buffered, currentTime, duration } = this.video;
10650
+ let ahead = 0;
10651
+ let totalBuffered = 0;
10652
+ for (let i = 0; i < buffered.length; i++) {
10653
+ const start = buffered.start(i);
10654
+ const end = buffered.end(i);
10655
+ totalBuffered += end - start;
10656
+ if (currentTime >= start - 0.1 && currentTime <= end) {
10657
+ ahead = Math.max(0, end - currentTime);
10658
+ }
10659
+ }
10660
+ if (Number.isFinite(duration) && duration > 0) {
10661
+ const pct = Math.min(100, (totalBuffered / duration) * 100).toFixed(0);
10662
+ return `${ahead.toFixed(1)}s ahead (${pct}% buffered)`;
10663
+ }
10664
+ return `${ahead.toFixed(1)}s ahead`;
10183
10665
  }
10184
10666
  }
10185
10667
 
10186
- /* global "1.0.0" */
10668
+ /* global "1.1.0" */
10187
10669
  let index = 0;
10188
10670
  const instances = [];
10189
10671
  class NeoPlayer {
@@ -10854,12 +11336,12 @@ class NeoPlayer {
10854
11336
  this.events.trigger('destroy');
10855
11337
  }
10856
11338
  static get version() {
10857
- return "1.0.0";
11339
+ return "1.1.0";
10858
11340
  }
10859
11341
  }
10860
11342
 
10861
- /* global "1.0.0" "55672b9" */
10862
- console.log(`${'\n'} %c NeoPlayer v${"1.0.0"} ${"55672b9"} %c https://github.com/Fluxonide/NeoPlayer ${'\n'}${'\n'}`, 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
11343
+ /* global "1.1.0" "af9d9ca" */
11344
+ console.log(`${'\n'} %c NeoPlayer v${"1.1.0"} ${"af9d9ca"} %c https://github.com/Fluxonide/NeoPlayer ${'\n'}${'\n'}`, 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
10863
11345
 
10864
11346
  export { NeoPlayer as default };
10865
11347
  //# sourceMappingURL=NeoPlayer.esm.js.map