Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-audio

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-audio

Audio Player Component for Svelte.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
63
increased by10.53%
Maintainers
1
Weekly downloads
 
Created
Source

Svelte Audio

Audio Player Component for Svelte.

It uses APlayer under the hood!

Installation

pnpm i -D svelte-audio

Usage

<script lang="ts">
    import { Audio } from "svelte-audio";
    import { playlist } from "./playlist";

    let paused = false;
    let time = 0;
    let volume = 1;
    let mini = false;
</script>

<audio bind:paused bind:time bind:volume bind:mini {playlist}>
    <!-- Loading Slot -->
    <div>Loading ...</div>
</audio>

Paused: <input type="checkbox" bind:checked="{paused}" /> Volume:
<input type="range" min="0" max="1" step="0.01" bind:value="{volume}" /> Mini:
<input type="checkbox" bind:checked="{mini}" /> Current Time: {time}s
playlist.ts
import type { Playlist } from "svelte-audio";

export const playlist: Playlist = [
    {
        name: "ChatGPT Help Me!",
        artist: "Jacob, GPT-4, Suno v3",
        cover: "https://cdn1.suno.ai/image_6aee2edf-ba1e-4394-b75e-7385261c4e07.png",
        url: "https://cdn1.suno.ai/ebb95c9f-ef34-4cd1-b0f1-d8a97666550a.mp3",
        lrc: "https://storage.jacoblin.cool/ChatGPT-Help-Me.lrc",
    },
    {
        name: "Flavors of the Night: Taipei",
        artist: "Jacob, GPT-4, Suno v3",
        cover: "https://cdn1.suno.ai/image_3400c31e-d6ec-4101-80b1-1ae11dd3d220.png",
        url: "https://cdn1.suno.ai/3400c31e-d6ec-4101-80b1-1ae11dd3d220.mp3",
    },
];

screenshot

To see the full list of props, check out the Storybook.

Access to APlayer Instance

You can access the APlayer instance by using the .player() method.

<script lang="ts">
    import { Audio } from "svelte-audio";
    import { playlist } from "./playlist";

    let audio: Audio;

    function remove() {
        audio.player().list.clear();
    }
</script>

<Audio bind:this={audio} {playlist}>
    <div>Loading ...</div>
</Audio>

<button on:click={remove}> Remove Songs </button>

See all the API methods in the APlayer Documentation.

Keywords

FAQs

Package last updated on 04 Apr 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc