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

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];
}
}
}
}
主站蜘蛛池模板: 乡宁县| 双鸭山市| 怀安县| 敦化市| 河池市| 梓潼县| 清镇市| 澄迈县| 尉氏县| 山阴县| 商河县| 马边| 红河县| 福清市| 阿拉善左旗| 隆林| 广安市| 漳州市| 秦皇岛市| 海原县| 宜春市| 曲阳县| 连平县| SHOW| 盘锦市| 许昌市| 叶城县| 句容市| 米林县| 苏尼特右旗| 周口市| 庆阳市| 铜陵市| 宁强县| 德惠市| 仙桃市| 桑植县| 日喀则市| 阿克苏市| 鲁山县| 武穴市|