Socket
Book a DemoInstallSign in
Socket

@asset-manager/audio

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asset-manager/audio

A singleton for loading and retrieving audio assets used in your application.

0.0.3
latest
Source
npmnpm
Version published
Weekly downloads
3
Maintainers
2
Weekly downloads
 
Created
Source

@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

Keywords

javascript

FAQs

Package last updated on 23 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.