public static void Open(string filename) { if (Playing) { return; } btnPlay.Enabled = btnStop.Enabled = false; if (m_GZIn != null) { m_GZIn.Close(); } try { m_GZIn = new GZBlockIn(filename); //new BinaryReader( new FileStream( filename, FileMode.Open, FileAccess.Read, FileShare.Read ) ); m_Version = m_GZIn.Raw.ReadByte(); if (m_Version > PlayerVersion) { m_GZIn.Close(); m_GZIn = null; MessageBox.Show(Engine.MainWindow, Language.GetString(LocString.WrongVer), "Version Mismatch", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } m_GZIn.IsCompressed = m_Version > 1; byte[] filehash = m_GZIn.Raw.ReadBytes(16); DateTime created = DateTime.FromFileTime(m_GZIn.Raw.ReadInt64()); TimeSpan len = TimeSpan.FromMilliseconds(m_GZIn.Raw.ReadInt32()); string player = m_GZIn.Compressed.ReadString(); string shard = m_GZIn.Compressed.ReadString(); System.Net.IPAddress ip = System.Net.IPAddress.Any; try { if (m_Version > 1) { ip = new System.Net.IPAddress((long)m_GZIn.Compressed.ReadUInt32()); } } catch { } m_StartPos = (int)m_GZIn.Position; long rawPos = m_GZIn.RawStream.Position; m_GZIn.RawStream.Seek(1 + 16, SeekOrigin.Begin); using (MD5 md5 = MD5.Create()) { byte[] check = md5.ComputeHash(m_GZIn.RawStream); for (int i = 0; i < check.Length; i++) { if (check[i] != filehash[i]) { m_GZIn.Close(); m_GZIn = null; MessageBox.Show(Engine.MainWindow, Language.GetString(LocString.VideoCorrupt), "Damaged File", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } m_GZIn.RawStream.Seek(rawPos, SeekOrigin.Begin); m_CurLength = len; m_Elapsed = TimeSpan.Zero; UpdateTimeText(); m_RPVInfo = lblPlay.Text = String.Format("File: {0}\nLength: {1} ({2})\nDate: {3}\nRecorded by \"{4}\" on \"{5}\" ({6})\n", Path.GetFileName(filename), Utility.FormatTime((int)len.TotalSeconds), Utility.FormatSize(m_GZIn.RawStream.Length), created.ToString("M-dd-yy @ h:mmtt"), player, shard, ip); btnClose.Enabled = btnPlay.Enabled = btnStop.Enabled = true; tbPos.Maximum = (int)len.TotalSeconds; tbPos.Minimum = 0; } catch (Exception e) { if (e is FileNotFoundException) { MessageBox.Show(Engine.MainWindow, e.Message, "File not found.", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Engine.LogCrash(e); MessageBox.Show(Engine.MainWindow, Language.GetString(LocString.ReadError), "Read Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } m_GZIn.Close(); m_GZIn = null; return; } }