1.0.0 • Published 4 years ago

ngx-sounds v1.0.0

Weekly downloads
26
License
MIT
Repository
github
Last release
4 years ago

ngx-sounds

Angular howler.js wrapper service.

Demo

Getting Started

1. Install packages

npm i howler ngx-sounds

2. Import Module

import { NgxSoundsModule } from 'ngx-sounds';

@NgModule({
  declarations: [AppComponent],
  imports: [
    NgxSoundsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}

3. Include the service

import { SoundsService } from 'ngx-sounds';

export class AppComponent {

  constructor(
    private sounds: SoundsService
  ){}

  ngOnInit() {
    // Shortcut methods
    this.sounds.play('assets/my-sound.mp3')
      .subscribe(
        () => console.log('sound played!')
      );

    this.sounds.volume(0.5)

    this.sounds.mute();

    // Static accessor
    this.sounds.howler;

    // Howl factory
    const howl = this.sounds.howl({
      src: ['assets/my-sound.mp3']
    });

    howl.play();
  }

}