public void Connect(IPlayerCore core) { this.core = core; Console.CursorVisible = false; curLeft = 10; curTop = 0; timer = new Timer(); timer.Interval = 500; timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); lrc.Clear(); string fileName = core.CurrentFile; FileInfo info = new FileInfo(fileName); lrcFile = fileName.Replace(info.Extension, ".lrc"); if( File.Exists(lrcFile) ) { FileStream stream = new FileStream(lrcFile, FileMode.Open); BinaryReader breader = new BinaryReader(stream); byte[] buffer = new byte[stream.Length + 1]; breader.Read(buffer, 0, (int)stream.Length); stream.Close(); string bufferString = Encoding.Default.GetString(buffer); StringReader reader = new StringReader(bufferString); //lrcEncoding = reader.CurrentEncoding; string line; while( !string.IsNullOrEmpty(line = reader.ReadLine()) ) { //line = Encoding.Unicode.GetString(lrcEncoding.GetBytes(line)); if (line.Contains("[ti") || line.Contains("[ar") || line.Contains("[al") || line.Contains("[by") || line.Contains("[offset") ) continue; List<string> infos = GetStrings(line); if (infos.Count == 0) continue; string val = infos[infos.Count - 1]; for (int index = 0; index < infos.Count - 1; index++) { string timeVal = infos[index]; List<string> times = GetTimeStrings(timeVal); int minute = Int32.Parse(times[0]); int second = Int32.Parse(times[1]); TimeSpan span = new TimeSpan(0, minute, second); if (lrc.ContainsKey(span)) lrc[span] = val; else lrc.Add(span, val); } } } timer.Start(); }
public void Disconnect() { Console.Clear(); timer.Stop(); timer.Close(); this.core = null; }
public void Connect(IPlayerCore core) { Console.WriteLine("\nconnect!"); }
public bool NotifyConnection(IPlayerCore core) { foreach (object o in extensionList.Values) { IExtension ext = o as IExtension; if (ext == null) continue; IConnection connection = o as IConnection; if (connection != null) { connection.Connect(core); } } return true; }