Nutella with Pepperoni and Mushrooms

    @asset-manager/audio
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.3 • Public • Published

    @asset-manager/audio

    NPM version PR Welcome

    This package provides loaders for preloading audio type assets.

    Introduction

    This package contains two loaders that return either an audio buffer or base64 string that can be used as a source for the audio library of choice.

    Loading and retrieving assets.

    import AssetManager from "@asset-manager/core";
    import { AudioBufferLoader, AudioBase64Loader } from "@asset-manager/audio";
    
    // Get an instance to the manager and set the loaders
    const manager = AssetManager.getInstance();
    manager.setLoaders({
      audioBuffer: AudioBufferLoader,
      audioBase64: AudioBase64Loader,
    });
    
    // Set the assets to load
    manager.setAssets([
      {
        id: "bufferName",
        url: "static/audio/audioFile.m4a",
        type: "audioBuffer",
        preload: true,
        params: {
          audioContext: audio.audioContext,
        },
      },
      {
        id: "base64Name",
        url: "static/audio/audioFile.m4a",
        type: "audioBase64",
        preload: true,
      },
    ]);
    
    // Elsewhere in your app you can grab assets from the manager
    const buffer =
      AssetManager.getInstance().get<AudioBufferLoader>("bufferName").audioBuffer;
    
    const base64String =
      AssetManager.getInstance().get<AudioBase64Loader>("base64Name").audioBase64;

    Installation

    Install this package with npm.

    npm i @asset-manager/audio

    This package does not include the core loader. You will need to install that separately

    npm i @asset-manager/core

    Install

    npm i @asset-manager/audio

    DownloadsWeekly Downloads

    4

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    26.6 kB

    Total Files

    39

    Last publish

    Collaborators

    • robsouthgate
    • digitaljohn