npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

audio-giber

v1.6.3

Published

This is a library js for create a audio player

Downloads

22

Readme

AudioGiber

AudioGiber is a JavaScript library that allows you to easily create an audio player context. It provides a simple and convenient way to manage and play audio tracks within your application.

Installation

You can install AudioGiber using npm:

npm install audio-giber

Usage

To use AudioGiber, follow the steps below:

  1. Import the library into your JavaScript file:
import AudioGiber from 'audio-giber'
  1. Create an instance of the AudioGiber class, providing the required options:
const Player = new AudioGiber({
  name: 'My Audio Player', // Optional: The name of the audio player
  nameId: 'audio-player', // Optional: The ID of the audio player element
  arrayTracks: [
    // Optional: An array of audio track objects
    { id: 1, title: 'Track 1', src: 'path/to/track1.mp3' },
    { id: 2, title: 'Track 2', src: 'path/to/track2.mp3' },
    // Add more tracks as needed
  ],
  onEndContinueTrack: true, // Optional: Continue playing the next track when the audio ends
  startInTrackIndex: 0, // Optional: Start playing the audio at the specified track index
  DEV: false, // Optional: Enable development mode
  preload: true, // Optional: Preload the audio
  onEndTrack: (event) => {
    // Optional: Callback function when a track ends
    console.log('Track ended', event)
  },
  ready: (event) => {
    // Optional: Callback function when the audio is ready
    console.log('Audio ready', event)
  },
  src: 'path/to/audio.mp3', // Optional: Set the source audio
})

Audio Track Object

The audio tracks are represented as objects with the following properties:

  • id (number): The unique identifier for the track.
  • title (string): The title of the track.
  • src (string): The path to the audio file.
  • imageTrack (string, optional): The path to an image associated with the track.
  • subtitle (string, optional): The subtitle of the track.
  • album (string, optional): The album name of the track.

Player methods

import { AudioGiber, type AudioTrack } from 'audio-giber'
import tracks from 'tracks'

const Player: AudioGiber = new AudioGiber({
  name: 'My player',
  arrayTracks: tracks as AudioTrack[],
  preload: true,
  onEndContinueTrack: true,
})

// Get duration
const durationTrack1 = player.getDuration()
// --- or ---
const durationTrack2 = player.getCurrenTrack().duration

// Play or pause
player.play()
payer.pause()
// --- or ---
player.togglePlay((event: boolean) => {
  // if is playing so, audio is paused
  console.log(event) // this callback is optional
  // If the callback event is true, so audio is paused
})

// Set current track
player.setCurrentTrack({
  src: 'src/my-audio.mp3',
  title: 'My Audio',
  subtitle: 'By Erickgiber',
  imageTrack: 'my-audio-image.png',
  description: 'This is my favorite music!',
  author: 'Erickgiber',
  bitsVelocity: 320,
  copyright: false,
  isDownloadable: true,
}) // Now you audio track change

This methods and more

Contributing

Contributions to AudioGiber are welcome! If you encounter any issues or have suggestions for improvement, please open an issue on the GitHub repository. Pull requests are also appreciated.

License

MIT