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

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];
}
}
}
}
主站蜘蛛池模板: 新民市| 新兴县| 喜德县| 秦皇岛市| 信宜市| 滁州市| 永春县| 尚志市| 福清市| 开封市| 娄烦县| 博客| 沂水县| 阳城县| 昌都县| 浦城县| 贡嘎县| 泗阳县| 林口县| 科技| 广丰县| 曲阜市| 安福县| 贵南县| 嘉黎县| 彩票| 开鲁县| 凤台县| 左权县| 永修县| 长宁县| 新干县| 房山区| 高青县| 东乌珠穆沁旗| 三河市| 益阳市| 大英县| 革吉县| 称多县| 五台县|