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

gs-player

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gs-player

Simple and easy to use Angular 8 music player

  • 0.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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


NameDescription
PlayerStreamStateStream state, used to manage the file being played
PlayerFileA file to be played
PlayerCurrentFileFile being played
PlayerThemePlayer theme. Can be used to create themes
PlayerStreamState properties

NameType
playingbooleanrequired
readableCurrentTimestringrequired
readableDurationstringrequired
durationnumberundefined
currentTimenumberundefined
canplaybooleanrequired
errorbooleanrequired
PlayerFile properties

NameType
urlstringrequired
namestringrequired
artiststringoptional
albumstringoptional
PlayerCurrentFile properties

NameType
indexnumberrequired
filePlayerFilerequired
PlayerTheme properties

NameType
primarystringrequired
secondarystringrequired

Library constants

Constants can be used inside your project.

Available constants


NameDescription
PlayerThemeLightLight color theme, good for dark background
PlayerThemeDarkDark color theme, good for bright background
PlayerThemeLight properties

Namevalue
primary'#fff'
secondary'#eee'
PlayerThemeDark properties

Namevalue
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

Keywords

FAQs

Package last updated on 11 Jan 2020

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