public Audio(string name, string saveName, int matchScriptID) { Name = name; MatchScriptID = matchScriptID; SaveName = saveName; LengthMillis = AudioHelper.GetAudioLength(saveName); Length = AudioHelper.ConvertMillisToTime(LengthMillis); Type = AudioHelper.GetAudioType(saveName); }
/// <summary> /// Initialize Audio from a sound shape /// </summary> public Audio(Shape shape, string saveName) { // detect audio type from shape tag AudioType audioType = GetShapeAudioType(shape); this.Type = audioType; // derive matched id from shape name string[] temp = shape.Name.Split(new[] { ' ' }); if (temp.Length < 3) { throw new FormatException(NarrationsLabText.RecorderUnrecognizeAudio); } this.MatchScriptID = Int32.Parse(temp[2]); // get corresponding audio this.Name = shape.Name; this.SaveName = saveName; this.Length = AudioHelper.GetAudioLengthString(saveName); this.LengthMillis = AudioHelper.GetAudioLength(saveName); }