void playOldFileListName(lisVideo tmpvideo, string notice, DateTime start, DateTime endtime, byte byChannel, IntPtr hwind) { try { closeAll(); _playNow = false; var anotherP = tmpvideo.videoCfg.fileCfg; TMCC.tmPlayConditionCfg_t struCond = new TMCC.tmPlayConditionCfg_t(); struCond.dwSize = (UInt32)Marshal.SizeOf(struCond); struCond.byChannel = byChannel; //_getConfigHost.byChannel; struCond.struStartTime = anotherP.struStartTime; struCond.struStopTime = anotherP.struStopTime; struCond.byBufferBeforePlay = 1; struCond.dwBufferSizeBeforePlay = 1024 * 1024 * 20; DateTime tmpVideoStart = new DateTime(struCond.struStartTime.wYear, struCond.struStartTime.byMonth, struCond.struStartTime.byDay, struCond.struStartTime.byHour, struCond.struStartTime.byMinute, struCond.struStartTime.bySecond, (Int32)struCond.struStartTime.dwMicroSecond); DateTime tmpVideoEnd = new DateTime(struCond.struStopTime.wYear, struCond.struStopTime.byMonth, struCond.struStopTime.byDay, struCond.struStopTime.byHour, struCond.struStopTime.byMinute, struCond.struStopTime.bySecond, (Int32)struCond.struStopTime.dwMicroSecond); IntPtr p4 = Marshal.AllocHGlobal(Marshal.SizeOf(struCond)); Marshal.StructureToPtr(struCond, p4, false); IntPtr p6 = TMCC.TMCC_OpenFile(hLogin, p4, hwind); _currPlayfile = p6; _notice = notice; _byChannel = byChannel; _videoname = tmpvideo.nameVideo; _currPlayfileConfigList = anotherP; m_iPlaySpeed = 0; var iflag = TMCC.Avdec_PlayToDo(p6, TMCC.PLAY_CONTROL_PLAY, 0); if (iflag == 0) { _currPlayfilep = true; var getFileStatus = TMCC.Avdec_GetTmPlayStateCfg_t(_currPlayfile); _trackBar1alltime = Convert.ToInt32(getFileStatus.dwTotalTimes / 1000); _trackBar1currtime = Convert.ToInt32(getFileStatus.dwCurrentTimes / 1000); var diffsecStart = start - tmpVideoStart; var diffsecEnd = DateTime.Compare(endtime, tmpVideoEnd); if (diffsecEnd > 0) { _playNext = true; _nextStartPlay = tmpVideoEnd.AddSeconds(1); _nextEndPlay = endtime; _stopDiffMill = Convert.ToInt32(getFileStatus.dwTotalTimes / 1000); } else { _playNext = false; var stopDiffMill = endtime - tmpVideoStart; _stopDiffMill = Convert.ToInt32(stopDiffMill.TotalMilliseconds / 1000); } if (diffsecStart.TotalMilliseconds > 0) { timer1.Enabled = true; _currMsg = notice + "\n播放成功.";//,时间 playOnMini(diffsecStart.TotalMilliseconds); } //trackBar1.Maximum = 0; //trackBar1.Value = 0; } else { _currMsg = notice + "\n播放失败,请再次尝试.谢谢."; } lbl0Msg.Text = _currMsg; } catch (Exception ex) { _currPlayfilep = false; MessageBox.Show(notice + ",Play Error:" + ex.Message); //throw ex; } }
void playOldFileListName(string name, Dictionary<string, videoCfg> dic, string notice) { try { if (dic.ContainsKey(name)) { closeAll(); var anotherP = dic[name].fileCfg; TMCC.tmPlayConditionCfg_t struCond = new TMCC.tmPlayConditionCfg_t(); struCond.dwSize = (UInt32)Marshal.SizeOf(struCond); struCond.byChannel = 0; struCond.struStartTime = anotherP.struStartTime; struCond.struStopTime = anotherP.struStopTime; IntPtr p4 = Marshal.AllocHGlobal(Marshal.SizeOf(struCond)); Marshal.StructureToPtr(struCond, p4, false); IntPtr p6 = TMCC.TMCC_OpenFile(hLogin, p4, this.pictureBox1.Handle); _currPlayfile = p6; _notice = notice; _videoname = name; _currPlayfileConfigList = anotherP; m_iPlaySpeed = 0; var iflag = TMCC.Avdec_PlayToDo(p6, TMCC.PLAY_CONTROL_PLAY, 0); if (iflag == 0) { timer1.Enabled = true; _currMsg = notice + "【" + name + "】播放成功.";//,时间 } else { _currMsg = notice + "【" + name + "】播放失败,请再次尝试.谢谢."; } lbl0Msg.Text = _currMsg; } else { MessageBox.Show(notice + "," + name + "不存在.请选择正确的文件名。"); return; } } catch (Exception ex) { MessageBox.Show(notice + ",Play Error:" + ex.Message); //throw ex; } }