npm i ngx-audio-player
app.module.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; import { NgxAudioPlayerModule } from 'ngx-audio-player'; import { AppComponent } from './app.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, FormsModule, NgxAudioPlayerModule ], declarations: [ AppComponent ], bootstrap: [ AppComponent ] }) export class AppModule { } |
app.component.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import { Component } from '@angular/core'; @Component({ selector: 'my-app', templateUrl: './app.component.html', styleUrls: [ './app.component.css' ] }) export class AppComponent { number = '9'; playlist = [ { title: 'In Love | A Himitsu feat. Nori', link: 'https://dl.dropboxusercontent.com/s/9v0psowra7ekhxo/A%20Himitsu%20-%20In%20Love%20%28feat.%20Nori%29.flac?dl=0' }, { title: 'Cartoon – On & On (feat. Daniel Levi) [NCS Release]', link: 'https://dl.dropboxusercontent.com/s/w99exjxnwoqwz0e/Cartoon-on-on-feat-daniel-levi-ncs-release.mp3?dl=0' } ]; triggerOnEnded(event) { console.log('ended'); } } |
app.component.html
1 2 |
<div class="player"> <mat-advanced-audio-player |
1 2 3 4 5 6 7 8 9 |
="playlist" [displayTitle]="true" [displayPlaylist]="true" [pageSizeOptions]="[5, 10, 25, 100]" [autoPlay]="true" (trackEnded)="triggerOnEnded($event)" > </mat-advanced-audio-player> </div> |
FULL SOURCE CODE