@christianriedl/media 1.0.99 → 1.0.101

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@christianriedl/media",
3
- "version": "1.0.99",
3
+ "version": "1.0.101",
4
4
  "description": "RIC media interfaces",
5
5
 
6
6
  "main": "dist/index.js",
@@ -37,7 +37,8 @@
37
37
  let mouseTimer: number = -1;
38
38
  let nameTimer: number = -1;
39
39
  let nextIndex: number = -1;
40
- let mediaUrlLength = mediaService.mediaUrl;
40
+ let keepBlobs: boolean = true;
41
+ let mediaUrlLength = mediaService.mediaUrl.length;
41
42
  const showName = ref(false);
42
43
 
43
44
  watch([appState.bodyHeight, appState.pageWidth], () => {
@@ -89,6 +90,15 @@
89
90
  appState.fullScreenElement.value = null;
90
91
  window.document.removeEventListener('keydown', onKey);
91
92
  appState.navigate.value = onNavigate;
93
+ if (keepBlobs && mediaAppConfig.useImagePreload) {
94
+ for (let i = 0; i < items.length; i++) {
95
+ const item = items[i];
96
+ if (item.blob && item.blob.startsWith('blob')) {
97
+ window.URL.revokeObjectURL(item.blob);
98
+ item.blob = undefined;
99
+ }
100
+ }
101
+ }
92
102
  });
93
103
  function onNavigate(direction: EDirection): void {
94
104
  if (direction === EDirection.Left)
@@ -363,7 +373,6 @@
363
373
  delete metadata['Personen'];
364
374
  }
365
375
  function onDownload() {
366
- //window.open(origUrl);
367
376
  const anchor = document.createElement("a");
368
377
  anchor.href = origUrl;
369
378
  anchor.download = items[index.value].Url;
@@ -385,8 +394,7 @@
385
394
  clearName();
386
395
  const item = items[index.value];
387
396
  if (mediaAppConfig.useImagePreload) {
388
- if (index.value != nextIndex) {
389
- item.blob = appConfig.urlPrefix + "img/Wait.png";
397
+ if (index.value != nextIndex && !item.blob) {
390
398
  createBlob(item);
391
399
  }
392
400
  }
@@ -398,12 +406,13 @@
398
406
  function onLoad(item: IPictureFile) { // img loaded or cached
399
407
  if (mediaAppConfig.useImagePreload) {
400
408
  if (item.blob && item.blob.startsWith("blob")) {
401
- window.URL.revokeObjectURL(item.blob);
402
- }
403
- const next = index.value + 1;
404
- if (next < items.length && next > nextIndex) {
405
- nextIndex = next;
406
- createBlob(items[nextIndex]);
409
+ if (!keepBlobs)
410
+ window.URL.revokeObjectURL(item.blob);
411
+ const next = index.value + 1;
412
+ if (next < items.length && next > nextIndex) {
413
+ nextIndex = next;
414
+ createBlob(items[nextIndex]);
415
+ }
407
416
  }
408
417
  }
409
418
  clearName();
@@ -424,6 +433,7 @@
424
433
  }
425
434
  }
426
435
  function createBlob (item: IPictureFile) {
436
+ item.blob = appConfig.urlPrefix + "img/Wait.png";
427
437
  const url = getUrl(item).substr(mediaUrlLength); // trim mediaserver url
428
438
  mediaService.getImage(url)
429
439
  .then((blob) => {