Now, let's create the API our services will provide to our app. Starting with PlayerService, we could imagine the following API might be useful to manage tracks and control playback. Most of it should be fairly self-explanatory. We may refactor this later but this is a great start:
- playing: boolean;
- tracks: Array<ITrack>;
- play(index: number): void;
- pause(index: number): void;
- addTrack(track: ITrack): void;
- removeTrack(track: ITrack): void;
- reorderTrack(track: ITrack, newIndex: number): void;
Create app/modules/player/services/player.service.ts and stub out a few of the methods; some of them we could go ahead and implement:
// angularimport { Injectable } from '@angular/core';// appimport { ITrack } from ...