Private StaticcreateCreates an HTTP GET request for the specified URL.
Private StaticgetExtracts the filename from a URL. Removes query parameters and fragments.
Private Static OptionalstorageStaticinitializeInitializes the storage for the RemoteMediaModule. Call this once to set a default storage for all media loading operations. After initialization, storage parameter becomes optional for loadAsPixmap and loadAsMovie.
The storage instance to use as default for media loading
import { RemoteMediaModule } from 'LensStudio:RemoteMediaModule.js';
import { ScopedStorage } from 'LensStudio:ScopedStorage.js';
// Initialize once at startup
RemoteMediaModule.initializeStorage(new ScopedStorage());
// Then use without passing storage
const pixmap = await RemoteMediaModule.loadAsPixmap('https://example.com/image.png');
StaticloadLoads content from a URL as a byte array.
The URL to load from
Promise resolving to the response body as a Uint8Array
StaticloadLoads and parses JSON content from a URL.
The URL to load from
Promise resolving to the parsed JSON object
StaticloadLoads a video from a URL and creates a Movie. The video is downloaded, saved to storage, and then loaded as a Movie.
The URL of the video
Optionalstorage: IStorageOptional storage instance. If not provided, uses the storage from initializeStorage()
Promise resolving to a Movie object
// Option 1: Pass storage directly
const storage = new ScopedStorage();
const movie = await RemoteMediaModule.loadAsMovie('https://example.com/video.mp4', storage);
// Option 2: Use initialized storage
RemoteMediaModule.initializeStorage(new ScopedStorage());
const movie = await RemoteMediaModule.loadAsMovie('https://example.com/video.mp4');
StaticloadLoads an image from a URL and creates a Pixmap. The image is downloaded, saved to storage, and then loaded as a Pixmap.
The URL of the image
Optionalstorage: IStorageOptional storage instance. If not provided, uses the storage from initializeStorage()
Promise resolving to a Pixmap object
// Option 1: Pass storage directly
const storage = new ScopedStorage();
const pixmap = await RemoteMediaModule.loadAsPixmap('https://example.com/image.png', storage);
// Option 2: Use initialized storage
RemoteMediaModule.initializeStorage(new ScopedStorage());
const pixmap = await RemoteMediaModule.loadAsPixmap('https://example.com/image.png');
StaticloadLoads content from a URL as a string.
The URL to load from
Promise resolving to the response body as a string
Static utility class for loading various types of media from URLs. All methods are asynchronous and return Promises.
Remarks
This module requires:
LensStudio:Network- For HTTP requestsLensStudio:Ui- For Pixmap and Movie typesIStoragefrom FileSystem module - For file operations (Pixmap/Movie only)Usage Patterns
Option 1: Initialize storage once (recommended for multiple media loads)
Option 2: Pass storage per call