visualfries 0.1.5 → 0.1.6

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.
@@ -399,9 +399,10 @@ export class SceneBuilder {
399
399
  this.appManager.destroy();
400
400
  this.domManager.destroy();
401
401
  this.stateManager.destroy();
402
- this.mediaManager.destroy();
403
402
  this.timelineManager.destroy();
404
403
  this.componentsManager.destroy();
404
+ // media manages should be destroyed last
405
+ this.mediaManager.destroy();
405
406
  // Remove the container from the DI container cache
406
407
  removeContainer(this.sceneData.id);
407
408
  }
@@ -229,6 +229,16 @@ export class MediaHook {
229
229
  async #handleDestroy() {
230
230
  this.#destroyed = true;
231
231
  this.#lastTargetTime = null;
232
+ // Release the media element back to the MediaManager
233
+ if (this.#mediaElement) {
234
+ const mediaType = this.#context.type === 'VIDEO' ? 'video' : 'audio';
235
+ const source = this.#context.contextData.source;
236
+ if (source && source.url) {
237
+ this.mediaManager.releaseMediaElement(source.url, mediaType);
238
+ }
239
+ this.#context.removeResource(mediaType === 'video' ? 'videoElement' : 'audioElement');
240
+ }
241
+ this.#mediaElement = undefined;
232
242
  }
233
243
  async handle(type, context) {
234
244
  this.#context = context;
@@ -91,7 +91,9 @@ export class MediaSeekingHook {
91
91
  };
92
92
  // Add error event handling
93
93
  media.onerror = () => {
94
- console.error('Media error:', media.error);
94
+ if (media.error && media.error.code !== 4) {
95
+ console.error('Media error:', media.src, media.error);
96
+ }
95
97
  };
96
98
  }
97
99
  }
@@ -100,6 +102,7 @@ export class MediaSeekingHook {
100
102
  await this.#handleSetup();
101
103
  }
102
104
  async #handleDestroy() {
105
+ // Clear media element reference - MediaHook will handle releaseMediaElement
103
106
  this.#mediaElement = undefined;
104
107
  }
105
108
  async #handleUpdate() {
@@ -181,6 +181,7 @@ export class MediaManager {
181
181
  if (type === 'video') {
182
182
  const videoElement = this.videoElements.get(mediaPath);
183
183
  if (videoElement) {
184
+ // https://html.spec.whatwg.org/multipage/media.html#best-practices-for-authors-using-media-elements
184
185
  videoElement.src = '';
185
186
  videoElement.load(); // This frees up memory
186
187
  this.videoElements.delete(mediaPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "visualfries",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "license": "MIT",
5
5
  "author": "ContentFries",
6
6
  "repository": {