官术网_书友最值得收藏!

A shared model for our data

Before we go about creating our services, let's create an interface and model implementation for the core piece of data our app will be using. The TrackModel will represent a single track with the following:

  • filepath: (to the local file)
  • name: (for our view)
  • order: Position (for the view listing of tracks)
  • volume: We want our player to be able to mix different tracks together with different volume level settings
  • solo: Whether we want to hear just this track in our mix

We will also add a convenient constructor to our model, which will take an object to initialize our model with.

Create app/modules/core/models/track.model.ts, since it will be shared across both our player and recorder:

export interface ITrack {
filepath?: string;
name?: string;
order?: number;
volume?: number;
solo?: boolean;
}
export class TrackModel implements ITrack {
public filepath: string;
public name: string;
public order: number;
public volume: number = 1; // set default to full volume
public solo: boolean;

constructor(model?: any) {
if (model) {
for (let key in model) {
this[key] = model[key];
}
}
}
}
主站蜘蛛池模板: 德兴市| 邛崃市| 宜良县| 栾川县| 茌平县| 汝阳县| 永康市| 裕民县| 宝兴县| 东至县| 康乐县| 平阳县| 邢台市| 绥阳县| 彭山县| 英德市| 黄浦区| 仁布县| 吉林市| 沙田区| 许昌市| 长阳| 景洪市| 敦化市| 井陉县| 奉化市| 南康市| 温泉县| 永年县| 龙泉市| 临海市| 依兰县| 辛集市| 徐水县| 玛多县| 河西区| 太谷县| 平顺县| 时尚| 璧山县| 江津市|