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

gs-player

v0.2.5

Published

Simple and easy to use Angular 8 music player

Downloads

203

Readme

gs-player

Simple music player user interface that easily adapts to any website interface.

Gs player - dark theme

Try the demo

Current version: Beta

This libriry was inspired by rxjs-audio and uses part of its source code. Thank you imsingh for let me use your tutorial and library.

Table of contents:

Installation

npm install gs-player --save

Getting Started

Add GsPlayerModule into the imports array of the module that will use gs-player

import { GsPlayerModule} from 'gs-player';

@NgModule({
  imports: [
    // ...
    GsPlayerModule
  ],
})
export class AppModule { }

Usage

Add gs-player to your code:

Add gs-player component to your HTML, import interfaces and define properties

HTML ex. app.component.html
<h1>My website</h1>
<gs-player></gs-player>
TS ex. app.component.ts
import { PlayerFile, PlayerTheme, PlayerThemeDark, PlayerThemeLight } from 'gs-player';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})
export class AppComponent {
  // Array of PlayerFiles (file url, name, artist and album)
  public files: Array<PlayerFile>;
  // Player color theme (one of PlayerThemeDark or PlayerThemeLight)
  // You can also crete your own color theme
  public playerTheme: PlayerTheme = PlayerThemeLight;

Pass tracks to gs-player:

To play audio in gs-player you must pass the files property. An array of PlayerFile:

HTML ex. app.component.html
<h1>My website</h1>
<gs-player
  [files]="files">
</gs-player>
TS ex. app.component.ts
export class AppComponent {
  // Array of PlayerFiles (file url, name, artist and album)
  // artist and album are optionals
  public files: Array<PlayerFile> = files: Array<PlayerFile> = [
    {
      url: 'url-to-audio-file.mp3',
      name: 'My audio',
      artist: 'Me',
      album: 'My album'
    }
  ];

At this point you should be able to play audio using gs-player.

Customise gs-player:

You can change gs-player color to fit your UI. The library have to themes by default:

  • PlayerThemeLight: For dark background
  • PlayerThemeDark: For bright background

Use themes as follow:

HTML ex. app.component.html
<h1>My website</h1>
<gs-player
  [files]="files"
  [playerTheme]="playerTheme">
</gs-player>
TS ex. app.component.ts
// import themes from `gs-player`
import { PlayerThemeDark, PlayerThemeLight } from 'gs-player';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})
export class AppComponent {
  public playerTheme = PlayerThemeLight;

You can create your own themes using your own colors:

TS ex. app.component.ts
// import PlayerTheme interface from `gs-player`
import { PlayerTheme } from 'gs-player';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})
export class AppComponent {
  public playerTheme: {
    // HTML/CSS Color Name, Hex Code #RRGGBB, Decimal Code (R,G,B)
    primary: 'red',
    secondary: 'blue'
  };

Library interfaces

Interfaces can be used inside your project.

Available interfaces

| Name | Description | |---------------------------|-------------------------------------------------------------| | PlayerStreamState | Stream state, used to manage the file being played | | PlayerFile | A file to be played | | PlayerCurrentFile | File being played | | PlayerTheme | Player theme. Can be used to create themes |

PlayerStreamState properties

| Name | Type | | |---------------------------|----------------------------|---------------------------| | playing | boolean | required | | readableCurrentTime | string | required | | readableDuration | string | required | | duration | number | undefined | required | | currentTime | number | undefined | required | | canplay | boolean | required | | error | boolean | required |

PlayerFile properties

| Name | Type | | |---------------------------|----------------------------|---------------------------| | url | string | required | | name | string | required | | artist | string | optional | | album | string | optional |

PlayerCurrentFile properties

| Name | Type | | |---------------------------|----------------------------|----------------------------| | index | number | required | | file | PlayerFile | required |

PlayerTheme properties

| Name | Type | | |---------------------------|----------------------------|----------------------------| | primary | string | required | | secondary | string | required |

Library constants

Constants can be used inside your project.

Available constants

| Name | Description | |---------------------------|-------------------------------------------------------------| | PlayerThemeLight | Light color theme, good for dark background | | PlayerThemeDark | Dark color theme, good for bright background |

PlayerThemeLight properties

| Name | value | |---------------------------|----------------------------| | primary | '#fff' | | secondary | '#eee' |

PlayerThemeDark properties

| Name | value | |---------------------------|----------------------------| | primary | '#222' | | secondary | '#eee' |

Testing

  1. Download the source code
  2. Install dependencies npm install
  3. Run demo ng serve

Versioning

gs-player will be maintained under the Semantic Versioning guidelines. Releases will be numbered with the following format:

<major>.<minor>.<patch>

For more information on SemVer, please visit http://semver.org.

Developer

Gustavo Santamaria

License

The MIT License (MIT)

Donate

If you like my work you can buy me a coffe or pizza

Donate