/// <summary> /// Statistics routine /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timerStatus_Tick(object sender, EventArgs e) { eMState eState; if (m_objPlaylist != null) { m_objPlaylist.ObjectStateGet(out eState); try { int nCount; double dblListLen; m_objPlaylist.PlaylistGetCount(out nCount, out dblListLen); if (nCount > 0) { int nCurFile, nNextFile = 0; double dblFilePos, dblListPos = 0; m_objPlaylist.PlaylistPosGet(out nCurFile, out nNextFile, out dblFilePos, out dblListPos); string strPath; MItem pItem; double dblListOffset; m_objPlaylist.PlaylistGetByIndex(nCurFile, out dblListOffset, out strPath, out pItem); double dblIn, dblOut, dblFileLen = 0; pItem.FileInOutGet(out dblIn, out dblOut, out dblFileLen); if (dblOut > dblIn) { dblFileLen = dblOut; } labelPos.Width = (int)((trackBarSeek.Width - 16) * dblListPos / dblListLen); string strFile = strPath.Substring(strPath.LastIndexOf('\\') + 1); labelStatus.Text = Dbl2PosStr(dblFilePos) + "/" + Dbl2PosStr(dblFileLen) + " " + eState.ToString() + " (" + (nCurFile + 1) + "/" + nCount + ") " + Dbl2PosStr(dblListPos) + "/" + Dbl2PosStr(dblListLen) + " " + "\r\n" + strFile + "\r\n" + strPath; System.Runtime.InteropServices.Marshal.ReleaseComObject(pItem); } GC.Collect(); } catch { labelStatus.Text = eState.ToString(); labelPos.Width = 0; } } }
private void timer1_Tick(object sender, EventArgs e) { if (aa) { return; } double a; double b; int c; int d; myPlaylist.PlaylistPosGet(out c, out d, out a, out b); trackBar2.Value = Convert.ToInt32(a); label4.Width = (trackBar2.Value * (trackBar2.Width - 20)) / trackBar2.Maximum; eMState eState; if (myPlaylist != null)//null exception için try-catch e alınmış. { myPlaylist.ObjectStateGet(out eState); try { int nCount; double dblListLen; myPlaylist.PlaylistGetCount(out nCount, out dblListLen); if (nCount > 0) { int nCurFile, nNextFile = 0; double dblFilePos, dblListPos = 0; myPlaylist.PlaylistPosGet(out nCurFile, out nNextFile, out dblFilePos, out dblListPos); string strPath; MItem pItem; double dblListOffset; myPlaylist.PlaylistGetByIndex(nCurFile, out dblListOffset, out strPath, out pItem); double dblIn, dblOut, dblFileLen = 0; pItem.FileInOutGet(out dblIn, out dblOut, out dblFileLen); if (dblOut > dblIn) { dblFileLen = dblOut; } string strFile = strPath.Substring(strPath.LastIndexOf('\\') + 1); label3.Text = Dbl2PosStr(dblFilePos) + "/" + Dbl2PosStr(dblFileLen) + " " + eState.ToString() + " (" + (nCurFile + 1) + "/" + nCount + ") " + Dbl2PosStr(dblListPos) + "/" + Dbl2PosStr(dblListLen) + " " + "\r\n" + strFile + "\r\n" + strPath; System.Runtime.InteropServices.Marshal.ReleaseComObject(pItem); } GC.Collect(); } catch { label4.Width = 0; throw; } string Dbl2PosStr(double _dblPos) { int nHour = (int)_dblPos / 3600; int nMinutes = ((int)_dblPos % 3600) / 60; int nSec = ((int)_dblPos % 60); _dblPos -= (int)_dblPos; int nMsec = (int)(_dblPos * 1000 + 0.5); string strRes = nHour.ToString("00") + ":" + nMinutes.ToString("00") + ":" + nSec.ToString("00") + "." + nMsec.ToString("000"); return(strRes); } } }