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

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];
}
}
}
}
主站蜘蛛池模板: 翁源县| 沈丘县| 明溪县| 文水县| 民县| 商洛市| 长垣县| 行唐县| 沙雅县| 石屏县| 铜陵市| 建德市| 定西市| 华池县| 佛坪县| 怀集县| 扶余县| 筠连县| 周宁县| 阿克| 远安县| 德令哈市| 成安县| 油尖旺区| 高州市| 晴隆县| 尉犁县| 清河县| 新密市| 淳化县| 鄂尔多斯市| 张家港市| 郁南县| 泸州市| 宁陕县| 岳阳县| 庆安县| 莱芜市| 芒康县| 左权县| 尉氏县|