O'Reilly logo

NativeScript for Angular Mobile Development by Nathanael J. Anderson, Nathan Walker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required