Building the TrackPlayerModel for our multitrack player

We need each track to have its own instance of an audio player, as well as to expose an API to load the track's audio file. This will also provide a good place to expose the track's duration once the audio file is loaded.

Since this model will likely be shared across the entire app (foreseeably with recording playback in the future as well), we will create this with our other models in app/modules/shared/models/track-player.model.ts:

// libsimport { TNSPlayer } from 'nativescript-audio';// appimport { ITrack } from 

'./track.model';interface ITrackPlayer {  trackId: number;  duration: number;  readonly 

player: TNSPlayer;}export class TrackPlayerModel implements ITrackPlayer { public trackId: ...

Get NativeScript for Angular Mobile Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.