Howler.js: Support of Angular 2

Created on 23 Mar 2017  路  11Comments  路  Source: goldfire/howler.js

I want to use this in a Angular 2 App. Is this possible?

Most helpful comment

i did it, you don't have to init howler with angular app, just import it in your component and use it

import { Howl } from 'howler'


@Component({
  selector: 'page-welcome',
  templateUrl: 'welcome.html'
})
export class WelcomePage {

  constructor(public navCtrl: NavController) {

     var sound = new Howl({
      src: ['http://server8.mp3quran.net/ahmad_huth/001.mp3'],
      html5 :true
    });

    sound.play();

   }



}

All 11 comments

Yeah just import it as any other external library. Not really user ng2 in a long time but if I can import it for react you should be able to do that for NG2

If you are using TypeScript most likely you will have to declare/install a type for howler. Check it out here https://github.com/slavomirvojacek/adbrain-typescript-definitions/blob/master/howlerjs/howler.d.ts
or if you use Babel just do

import { Howl } from './howler'

Install howler:

npm install howler --save

Install typescript definition:

npm install @typings/howler --save-dev

Import howler in your class:

import { Howl } from 'howler'

npm wasn't able to find @typings/howler

Not found : @typings/howler

@almgwary didn't you forget the @ ? @typings/howler not typings/howler

found it here npm install --save @types/howler

@peterpeterparker
where to init it in angular 2 app ?

  • declarations
  • imports
  • bootstrap
  • entryComponents
  • providers

can you just show us an example ?

unfortunately I don't have a working example to share :(

i did it, you don't have to init howler with angular app, just import it in your component and use it

import { Howl } from 'howler'


@Component({
  selector: 'page-welcome',
  templateUrl: 'welcome.html'
})
export class WelcomePage {

  constructor(public navCtrl: NavController) {

     var sound = new Howl({
      src: ['http://server8.mp3quran.net/ahmad_huth/001.mp3'],
      html5 :true
    });

    sound.play();

   }



}

May Allah bless you my friend , it was nice to hear the output as words of Allah <3

Was this page helpful?
0 / 5 - 0 ratings