12.0.2 • Published 7 months ago

ngx-audio-player v12.0.2

Weekly downloads
1,329
License
MIT
Repository
github
Last release
7 months ago

A library for loading and playing audio using HTML 5 for Angular 7/8/9/10/11/12.
(https://mudigal-technologies.github.io/ngx-audio-player/)

npm npm version Downloads licence Support Support Support Support Support Support

Table of contents

Demo

A simple, clean, responsive player for playing multiple audios with playlist support.

alt tag

Working Demo

Installation

ngx-audio-player is available via npm and yarn

Using npm:

$ npm install ngx-audio-player --save

Using yarn:

$ yarn add ngx-audio-player

Getting Started

NgxAudioPlayerModule needs Angular Material.
Make sure you have installed below dependencies with same or higher version than mentioned.

"@angular/core": "^12.0.0"
"@angular/common": "^12.0.0"
"@angular/material": "^12.0.0"
"rxjs": "^6.6.0"

Import NgxAudioPlayerModule in the root module(AppModule):

// Import library module
import { NgxAudioPlayerModule } from 'ngx-audio-player';

@NgModule({
  imports: [
    // ...
    NgxAudioPlayerModule
  ]
})
export class AppModule { }

Usage

Simple Audio Player

HTML
<ngx-audio-player [autoPlay]="false" muted="muted"
    
  [playlist]="mssapPlaylist"
  [disablePositionSlider]="mssapDisablePositionSlider"
  [displayRepeatControls]="mssapDisplayRepeatControls"
  [displayVolumeControls]="mssapDisplayVolumeControls"
  [displayVolumeSlider]="mssapDisplayVolumeSlider"

  [displayTitle]="mssapDisplayTitle"
  
  (trackEnded)="onEnded($event)">

</ngx-audio-player> 
TS
import { Track } from 'ngx-audio-player';   
   
.   
.   

mssapDisplayTitle = true;
mssapDisablePositionSlider = true;
mssapDisplayRepeatControls = true;
mssapDisplayVolumeControls = true;
mssapDisplayVolumeSlider = false;
   
// Material Style Simple Audio Player
mssapPlaylist: Track[] = [
  {
    title: 'Audio Title',
    link: 'Link to Audio URL',
    artist: 'Audio Artist',
    duration: 'Audio Duration in seconds'
  }
];

// For Streaming Audio From URL 
// set mediaType = 'stream' 
mssapPlaylist: Track[] = [
  {
    title: 'Audio Title',
    link: 'Link to Streaming URL',
    mediaType: 'stream'
  }
];

Advanced Audio Player

HTML
<ngx-audio-player [autoPlay]="false" muted="muted"

    [playlist]="msaapPlaylist"
    [disablePositionSlider]="msaapDisablePositionSlider"
    [displayRepeatControls]="msaapDisplayRepeatControls"
    [displayVolumeControls]="msaapDisplayVolumeControls"
    [displayVolumeSlider]="msaapDisplayVolumeSlider"
    
    [displayTitle]="msaapDisplayTitle"

    [displayPlaylist]="msaapDisplayPlayList"
    [pageSizeOptions]="msaapPageSizeOptions"

    [tableHeader]="msaapTableHeader"
    [titleHeader]="msaapTitleHeader"
    [artistHeader]="msaapArtistHeader"
    [durationHeader]="msaapDurationHeader"

    [displayArtist]="msaapDisplayArtist"
    [displayDuration]="msaapDisplayDuration"
    [expanded]="true"

    (trackPlaying)="onTrackPlaying($event)"
    (trackPaused)="onTrackPaused($event)"
    (trackEnded)="onEnded($event)"
    (nextTrackRequested)="onNextTrackRequested($event)"
    (previousTrackRequested)="onPreviousTrackRequested($event)"
    (trackSelected)="onTrackSelected($event)">

</ngx-audio-player>
TS
import { Track } from 'ngx-audio-player';   
   
.   
.   

// Main Player Controls
msaapDisplayPlayList = true;
msaapDisablePositionSlider = true;
msaapDisplayRepeatControls = true;
msaapDisplayVolumeControls = true;
msaapDisplayVolumeSlider = false;

// Title Marquee
msaapDisplayTitle = true;

// Playlist Controls
msaapPageSizeOptions = [2,4,6];
msaapDisplayArtist = false;
msaapDisplayDuration = false;

// For Localisation
msaapTableHeader = 'My Playlist';
msaapTitleHeader = 'My Title';
msaapArtistHeader = 'My Artist';
msaapDurationHeader = 'My Duration';


// Material Style Advance Audio Player Playlist
msaapPlaylist: Track[] = [
    {
        title: 'Audio One Title',
        link: 'Link to Audio One URL',
        artist: 'Artist',
        duration: 'Duration'
    },
    {
        title: 'Audio Two Title',
        link: 'Link to Audio Two URL',
        artist: 'Artist',
        duration: 'Duration'
    },
    {
        title: 'Audio Three Title',
        link: 'Link to Audio Three URL',
        artist: 'Artist',
        duration: 'Duration'
    },
];

// Callback Events

onTrackPlaying(event) {
    console.log(event);
    // your logic which needs to
    // be triggered once the
    // track ends goes here.
}


onTrackPaused(event) {
    console.log(event);
    // your logic which needs to
    // be triggered once the
    // track ends goes here.
}

onEnded(event) {
    console.log(event);
    // your logic which needs to
    // be triggered once the
    // track ends goes here.
}

onNextTrackRequested(event) {
    console.log(event);
    // your logic which needs to
    // be triggered once the
    // track ends goes here.
}


onPreviousTrackRequested(event) {
    console.log(event);
    // your logic which needs to
    // be triggered once the
    // track ends goes here.
}

onTrackSelected(event) {
    console.log(event);
    // your logic which needs to
    // be triggered once the
    // track ends goes here.
}
Properties
NameDescriptionType
@Input() playlist: Track[];playlist containing array of title and linkmandatory
@Input() autoPlay: false;true - if the audio needs to be played automaticllyoptional
Player Controls
@Input() startOffset = 0;offset from start of audio file in secondsoptional
@Input() endOffset = 0;offset from end of audio file in secondsoptional
@Input() disablePositionSlider = false;true - if the position slider needs to be disabledoptional
@Input() displayRepeatControls = true;false - if the repeat controls needs to be hiddenoptional
@Input() repeat: "all""one""none" = 'all';repeat all or one or noneoptional
@Input() displayVolumeControls = true;false - if the volume controls needs to be hiddenoptional
@Input() displayVolumeSlider = true;true - if the volume slider should be shownoptional
Title Marquee Control
@Input() displayTitle: true;false - if the audio title needs to be hiddenoptional
Playlist Controls
@Input() displayPlaylist: true;false - if the playlist needs to be hiddenoptional
@Input() pageSizeOptions = 10, 20, 30;number of items to be displayed in the playlistoptional
@Input() expanded = true;false - if the playlist needs to be minimizedoptional
@Input() displayArtist = false;true - if the artist data is to be shownoptional
@Input() displayDuration = false;true - if the track duration is to be shownoptional
Localisation Controls
@Input() tableHeader = 'Playlist';localised stringoptional
@Input() titleHeader = 'Title';localised stringoptional
@Input() artistHeader = 'Artist';localised stringoptional
@Input() durationHeader = 'Duration';localised stringoptional
Callback Events
@Output() trackPlaying: EventEmittertriggers when the track starts playingoptional
@Output() trackPaused: EventEmitterCallback method that triggers once the track endsoptional
@Output() trackEnded: EventEmitterCallback method that triggers once the track endsoptional
@Output() nextTrackRequested: EventEmitterCallback method that triggers once the track endsoptional
@Output() previousTrackRequested: EventEmitterCallback method that triggers once the track endsoptional
@Output() trackSelected: EventEmitterCallback method that triggers once the track endsoptional

Versioning

ngx-audio-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.

Contributors ✨

Thanks goes to these wonderful people:

Misc

License

The MIT License (MIT)

Donate

If you like my work you can buy me a :beer: or :pizza:

Donate

12.0.0

7 months ago

12.0.1

7 months ago

12.0.2

7 months ago

11.0.4

3 years ago

10.1.4

3 years ago

9.2.3

3 years ago

11.0.3

3 years ago

8.1.4

3 years ago

9.2.2

3 years ago

11.0.2

3 years ago

10.1.3

3 years ago

8.1.3

3 years ago

8.1.2

3 years ago

11.0.1

3 years ago

9.2.1

3 years ago

10.1.2

3 years ago

11.0.0

3 years ago

10.1.1

3 years ago

9.2.0

3 years ago

8.1.1

4 years ago

8.1.0

4 years ago

7.2.0

4 years ago

10.1.0

4 years ago

10.0.1

4 years ago

9.1.2

4 years ago

8.0.5

4 years ago

10.0.0

4 years ago

8.0.4

4 years ago

9.1.1

4 years ago

9.1.0

4 years ago

9.0.8

4 years ago

9.0.7

4 years ago

9.0.6

4 years ago

7.1.6

4 years ago

8.0.3

4 years ago

9.0.5

4 years ago

9.0.4

4 years ago

9.0.3

4 years ago

9.0.2

4 years ago

9.0.1

4 years ago

9.0.0

4 years ago

8.0.2

4 years ago

8.0.1

5 years ago

8.0.0

5 years ago

7.1.5

5 years ago

7.1.4

5 years ago

7.1.3

5 years ago

7.1.2

5 years ago

7.1.1

5 years ago

7.0.16

5 years ago

7.0.15

5 years ago

7.0.14

5 years ago

7.0.13

5 years ago

7.0.12

5 years ago

7.0.11

5 years ago

7.0.10

5 years ago

7.0.9

5 years ago

7.0.8

5 years ago

7.0.7

5 years ago

7.0.6

5 years ago

7.0.5

5 years ago

7.0.4

5 years ago

7.0.3

5 years ago

7.0.2

5 years ago

7.0.1

5 years ago

7.0.0

5 years ago