static public CueTime operator -(CueTime lhs, CueTime rhs) { CueTime c = (CueTime)lhs.MemberwiseClone(); if (c.Frames >= rhs.Frames) { c.Frames = c.Frames - rhs.Frames; } else { c.Frames = c.Frames + CueTime.FramesPerSecond - rhs.Frames; --c.Second; } if (c.Second >= rhs.Second) { c.Second = c.Second - rhs.Second; } else { c.Second = c.Second + 60 - rhs.Second; --c.Minute; } if (c.Minute >= rhs.Minute) { c.Minute -= rhs.Minute; } else { throw new ArgumentException("非法结果(不能从一个较小的时间减去一个较大的时间)"); } return(c); }
private void AdjustTime() { CueTime t = new CueTime(0, 0, 0); for (int i = 0; i < songs.Count - 1; i++) { if (songs[i + 1].EndTime.Equals(t)) { songs[i].EndTime = songs[i + 1].StartTime; } else { songs[i].EndTime = songs[i + 1].EndTime; } //t = songs[i].StartTime+new CueTime(0,0,2); //songs[i].StartTime = songs[i].EndTime; //if (i > 0) //{ // if (t.ToMiliSeconds() != 0) // { // songs[i - 1].EndTime = t; // } // else // { // songs[i - 1].EndTime = songs[i].StartTime; // } //} } songs[songs.Count - 1].EndTime = t; }
static public CueTime operator +(CueTime lhs, CueTime rhs) { CueTime t = ( CueTime )lhs.MemberwiseClone(); t.Minute += rhs.Minute; t.Second += rhs.Second; t.Frames += rhs.Frames; if (t.Frames >= CueTime.FramesPerSecond) { ++t.Second; t.Frames -= FramesPerSecond; } if (t.Second >= 60) { ++t.Minute; t.Second -= 60; } return(t); }
public static bool TryParse(string from, out CueTime time) { string[] arr = from.Split(':'); if (arr.Length == 3) { uint m = 0, s = 0, f = 0; if (uint.TryParse(arr[0], out m) && uint.TryParse(arr[1], out s) && uint.TryParse(arr[2], out f)) { time.Minute = m; time.Second = s; time.Frames = f; return(true); } } time = new CueTime(0); return(false); }
public static bool TryParse(string from, out CueTime time) { string[] arr = from.Split(':'); if (arr.Length == 3) { uint m = 0, s = 0, f = 0; if (uint.TryParse(arr[0], out m) && uint.TryParse(arr[1], out s) && uint.TryParse(arr[2], out f)) { time.Minute = m; time.Second = s; time.Frames = f; return true; } } time = new CueTime(0); return false; }
private void AdjustTime() { CueTime t =new CueTime(0,0,0); for (int i = 0; i < songs.Count-1; i++) { if (songs[i + 1].EndTime.Equals(t)) { songs[i].EndTime = songs[i + 1].StartTime; } else { songs[i].EndTime = songs[i + 1].EndTime; } //t = songs[i].StartTime+new CueTime(0,0,2); //songs[i].StartTime = songs[i].EndTime; //if (i > 0) //{ // if (t.ToMiliSeconds() != 0) // { // songs[i - 1].EndTime = t; // } // else // { // songs[i - 1].EndTime = songs[i].StartTime; // } //} } songs[songs.Count - 1].EndTime = t; }
private CueSongInfo ReadTrackInfo(StreamReader reader, CueSongInfo model) { CueSongInfo info = model.Clone() as CueSongInfo ; while (!reader.EndOfStream) { string str = reader.ReadLine().Trim(); if (string.IsNullOrEmpty(str)) { continue; } int splitpos = str.IndexOf(' '); string cmd = str.Substring(0, splitpos).ToUpper(); string value = str.Substring(splitpos).Replace('\"', ' ').Trim(); switch (cmd) { case "TITLE": info.Title = value.Trim (); break; case "PERFORMER": info.Artist = value.Trim(); break; case "GERNE": info.Genre = value.Trim(); break; case "YEAR": info.Year = value.Trim(); break; case "ISRC": info.Isrc = value.Trim(); break; case "INDEX": int timesplit = value.IndexOf(' '); string type = value.Substring(0, timesplit); string tstr = value.Substring(timesplit).Trim(); CueTime time = new CueTime(0,0,0); if (CueTime.TryParse(tstr, out time)) { if (type == "01") { info.StartTime = time; } else { info.EndTime = time; } } break; case "REM": string v2cmd = value.Substring(0, value.IndexOf(' ')).ToUpper(); string v2value = value.Substring(value.IndexOf(' ')); if (v2cmd == "DATE") { model.Year = v2value.Trim (); } else if (v2cmd == "GENRE") { model.Genre = v2value.Trim(); } break; case "TRACK": int t; if (int.TryParse(value.Substring(0, 2), out t)) model.Track = t; CueSongInfo song = ReadTrackInfo(reader, model); songs.Add(song); break; } } return info; }
private CueSongInfo ReadTrackInfo(StreamReader reader, CueSongInfo model) { CueSongInfo info = model.Clone() as CueSongInfo; while (!reader.EndOfStream) { string str = reader.ReadLine().Trim(); if (string.IsNullOrEmpty(str)) { continue; } int splitpos = str.IndexOf(' '); string cmd = str.Substring(0, splitpos).ToUpper(); string value = str.Substring(splitpos).Replace('\"', ' ').Trim(); switch (cmd) { case "TITLE": info.Title = value.Trim(); break; case "PERFORMER": info.Artist = value.Trim(); break; case "GERNE": info.Genre = value.Trim(); break; case "YEAR": info.Year = value.Trim(); break; case "ISRC": info.Isrc = value.Trim(); break; case "INDEX": int timesplit = value.IndexOf(' '); string type = value.Substring(0, timesplit); string tstr = value.Substring(timesplit).Trim(); CueTime time = new CueTime(0, 0, 0); if (CueTime.TryParse(tstr, out time)) { if (type == "01") { info.StartTime = time; } else { info.EndTime = time; } } break; case "REM": string v2cmd = value.Substring(0, value.IndexOf(' ')).ToUpper(); string v2value = value.Substring(value.IndexOf(' ')); if (v2cmd == "DATE") { model.Year = v2value.Trim(); } else if (v2cmd == "GENRE") { model.Genre = v2value.Trim(); } break; case "TRACK": int t; if (int.TryParse(value.Substring(0, 2), out t)) { model.Track = t; } CueSongInfo song = ReadTrackInfo(reader, model); songs.Add(song); break; } } return(info); }