private List<lisVideo> getListMoveFromStartAnd(DateTime startTime, DateTime endTime, string notice, byte byChannel) { var tmpdic = new List<lisVideo>(); videoCfg tmpvideo = null; var tmpfilename = "视频" + (tmpdic.Count + 1).ToString(); try { Cursor.Current = Cursors.WaitCursor; //this.button1.Enabled = false; if (startTime > DateTime.Now) { //dateTimePicker2.Focus(); tmpmsg = notice + " Error:结束时间大于当前时间。" + DateTime.Now; SetMsg(lbl0Msg, tmpmsg); return tmpdic; } if (startTime > endTime) { //dateTimePicker1.Focus(); tmpmsg = notice + " Error:开始时间大于结束时间。"; SetMsg(lbl0Msg, tmpmsg); return tmpdic; } TMCC.tmFindConditionCfg_t ConditionCfg = new TMCC.tmFindConditionCfg_t(); TMCC.tmFindFileCfg_t FileCfg = new TMCC.tmFindFileCfg_t(); ConditionCfg.dwSize = (UInt32)Marshal.SizeOf(ConditionCfg); ConditionCfg.byChannel = byChannel; //_getConfigHost.byChannel; //通道 ConditionCfg.byFileType = 0xFF; //录像文件类型 ConditionCfg.bySearchAllTime = 1; /*起始时间*/ ConditionCfg.struStartTime.wYear = Convert.ToUInt16(startTime.Year);// 2015; //年 ConditionCfg.struStartTime.byMonth = Convert.ToByte(startTime.Month);// 10; //月 ConditionCfg.struStartTime.byDay = Convert.ToByte(startTime.Day);//30; //日 ConditionCfg.struStartTime.byHour = Convert.ToByte(startTime.Hour);//0; //时 ConditionCfg.struStartTime.byMinute = Convert.ToByte(startTime.Minute);//0; //分 ConditionCfg.struStartTime.bySecond = Convert.ToByte(startTime.Second);//0; /*结束时间*/ ConditionCfg.struStopTime.wYear = Convert.ToUInt16(endTime.Year); //年 ConditionCfg.struStopTime.byMonth = Convert.ToByte(endTime.Month); //月 ConditionCfg.struStopTime.byDay = Convert.ToByte(endTime.Day); ; //日 ConditionCfg.struStopTime.byHour = Convert.ToByte(endTime.Hour); ; //时 ConditionCfg.struStopTime.byMinute = Convert.ToByte(endTime.Minute); ; //分 ConditionCfg.struStopTime.bySecond = Convert.ToByte(endTime.Second); ; ConditionCfg.byEnableServer = 0; ConditionCfg.byOldServer = 1; ConditionCfg.byBackupData = 0; ConditionCfg.dwServerPort = 6002; ConditionCfg.sServerAddress = _getConfigHost.cmsip;// "192.168.1.4";//.Get(32, txtIP.Text.ToCharArray());// string.Format("{0}", txtIP.Text.ToCharArray()); ConditionCfg.sUserName = _getConfigHost.userName;// "system";//.Get(32, txUser.Text.ToCharArray());// string.Format("{0}", txUser.Text.ToCharArray()); ConditionCfg.sUserPass = _getConfigHost.pswd;// "system";//.Get(32, txPswd.Text.ToCharArray());// string.Format("{0}", txPswd.Text.ToCharArray()); FileCfg.dwSize = (UInt32)Marshal.SizeOf(FileCfg); IntPtr p1 = Marshal.AllocHGlobal(Marshal.SizeOf(ConditionCfg)); Marshal.StructureToPtr(ConditionCfg, p1, false); IntPtr p2 = Marshal.AllocHGlobal(Marshal.SizeOf(FileCfg)); Marshal.StructureToPtr(FileCfg, p2, true); _hfile = TMCC.TMCC_FindFirstFile(hLogin, p1, p2); TMCC.tmFindFileCfg_t anotherP = (TMCC.tmFindFileCfg_t)Marshal.PtrToStructure(p2, typeof(TMCC.tmFindFileCfg_t)); ///************************************* tmpfilename = "视频" + (tmpdic.Count + 1).ToString(); if (string.IsNullOrEmpty(anotherP.sFileName)) { return tmpdic; } tmpvideo = new videoCfg(); tmpvideo.filename = anotherP.sFileName; tmpvideo.fileCfg = anotherP; lisVideo tmpListVideo = new lisVideo(); tmpListVideo.nameVideo = tmpfilename; tmpListVideo.videoCfg = tmpvideo; tmpdic.Add(tmpListVideo); ///************************************* do { IntPtr p3 = Marshal.AllocHGlobal(Marshal.SizeOf(anotherP)); Marshal.StructureToPtr(FileCfg, p3, false); var rest = TMCC.TMCC_FindNextFile(_hfile, p3); if (rest != TMCC.TMCC_ERR_SUCCESS) { break; } anotherP = (TMCC.tmFindFileCfg_t)Marshal.PtrToStructure(p3, typeof(TMCC.tmFindFileCfg_t)); ///************************************* tmpfilename = "视频" + (tmpdic.Count + 1).ToString(); var tmpvideoDO = new videoCfg(); tmpvideoDO.filename = anotherP.sFileName; tmpvideoDO.fileCfg = anotherP; lisVideo tmpListVideoN = new lisVideo(); tmpListVideoN.nameVideo = tmpfilename; tmpListVideoN.videoCfg = tmpvideoDO; tmpdic.Add(tmpListVideoN); ///************************************* } while (true); TMCC.TMCC_FindCloseFile(_hfile); return tmpdic; } catch (Exception ex) { MessageBox.Show(notice + ": " + ex.Message); return tmpdic; //throw ex; } finally { Cursor.Current = Cursors.Default; //this.button1.Enabled = true; } }
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; } }