goldfire / howler.js

Javascript audio library for the modern web.
https://howlerjs.com
MIT License
23.85k stars 2.23k forks source link

Support of Angular 2 #727

Closed Apfelkuchen91 closed 4 years ago

Apfelkuchen91 commented 7 years ago

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

Jerczu commented 7 years ago

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'

peterpeterparker commented 7 years ago

Install howler:

npm install howler --save

Install typescript definition:

npm install @typings/howler --save-dev

Import howler in your class:

import { Howl } from 'howler'
pinnprophead commented 7 years ago

npm wasn't able to find @typings/howler

almgwary commented 7 years ago

Not found : @typings/howler

peterpeterparker commented 7 years ago

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

almgwary commented 7 years ago

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

almgwary commented 7 years ago

@peterpeterparker where to init it in angular 2 app ?

almgwary commented 7 years ago

can you just show us an example ?

peterpeterparker commented 7 years ago

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

almgwary commented 7 years ago

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();

   }

}
ADFPassion commented 5 years ago

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