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-player-ts

v1.2.0

Published

Certainly! Here's an expanded README with all the functionalities of your audio player package along with usage examples:

Downloads

1

Readme

Certainly! Here's an expanded README with all the functionalities of your audio player package along with usage examples:


Audio Player

Description

A customizable audio player package built with TypeScript, providing features like play, pause, resume, next track, seek, volume control, and more.

Installation

Install the package in your project using npm or yarn:

npm install audio-player
# or
yarn add audio-player

Usage

  1. Import the AudioPlayer class in your React component:

    import React, { useState } from 'react';
    import AudioPlayer from 'audio-player';
    
    const App = () => {
        const [player] = useState(() => {
            const playlist = ['path/to/track1.mp3', 'path/to/track2.mp3']; // Example playlist
            return new AudioPlayer(playlist);
        });
    
        const [position, setPosition] = useState(0);
    
        const handleSeek = (value) => {
            setPosition(value);
            player.seek(value);
        };
    
        return (
            <div>
                <button onClick={() => player.play()}>Play</button>
                <button onClick={() => player.pause()}>Pause</button>
                <button onClick={() => player.resume()}>Resume</button>
                <button onClick={() => player.next()}>Next</button>
                <button onClick={() => player.increaseVolume()}>Increase Volume</button>
                <button onClick={() => player.decreaseVolume()}>Decrease Volume</button>
                <input
                    type="range"
                    min="0"
                    max="100"
                    value={position}
                    onChange={(e) => handleSeek(parseInt(e.target.value))}
                />
                {/* Add more buttons or controls as needed */}
            </div>
        );
    }
    
    export default App;
  2. Customize the player with your audio files and controls:

    • Replace 'path/to/track1.mp3', 'path/to/track2.mp3', etc., with the paths to your audio files.
    • Adjust the range input according to your design and UI requirements.
    • Add more buttons or controls by calling other methods of the AudioPlayer class, such as resume(), next(), increaseVolume(), decreaseVolume(), etc.
  3. Run your React app and test the audio player functionality:

    npm start

Functionality

  • play(): Start playing the current audio track.

    player.play();
  • pause(): Pause the currently playing audio track.

    player.pause();
  • resume(): Resume playback of the paused audio track.

    player.resume();
  • next(): Play the next track in the playlist.

    player.next();
  • seek(position: number): Seek to a specific position in the audio track (0-100).

    player.seek(50); // Seek to halfway through the track
  • increaseVolume(): Increase the volume of the audio player.

    player.increaseVolume();
  • decreaseVolume(): Decrease the volume of the audio player.

    player.decreaseVolume();
  • getCurrentTrackIndex(): Get the index of the currently playing track in the playlist.

    const currentIndex = player.getCurrentTrackIndex();
  • getPlaybackPosition(): Get the current playback position of the audio track.

    const position = player.getPlaybackPosition();
  • getVolume(): Get the current volume level of the audio player.

    const volume = player.getVolume();
  • setVolume(volume: number): Set the volume level of the audio player (0-1).

    player.setVolume(0.8); // Set volume to 80%

Documentation

For detailed API documentation and usage examples, refer to the Audio Player GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.


This README includes all the functionalities of your audio player package along with usage examples for each functionality. Users can refer to this README to understand how to use the package and its various features in their React projects. Adjust the examples and descriptions according to the actual implementation and API of your `AudioPlayer` class.