示例#1
0
        private void OnCLS(AMCPParserEventArgs e)
        {
            List <MediaInfo> clips = new List <MediaInfo>();

            foreach (string mediaInfo in e.Data)
            {
                string pathName   = mediaInfo.Substring(mediaInfo.IndexOf('\"') + 1, mediaInfo.IndexOf('\"', 1) - 1);
                string folderName = "";
                string fileName   = "";
                int    delimIndex = pathName.LastIndexOf('\\');
                if (delimIndex != -1)
                {
                    folderName = pathName.Substring(0, delimIndex);
                    fileName   = pathName.Substring(delimIndex + 1);
                }
                else
                {
                    fileName = pathName;
                }

                string    temp             = mediaInfo.Substring(mediaInfo.LastIndexOf('\"') + 1);
                string[]  vSizeTypeAndDate = temp.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                MediaType type             = (MediaType)Enum.Parse(typeof(MediaType), vSizeTypeAndDate[0]);
                Int64     size             = Int64.Parse(vSizeTypeAndDate[1]);
                DateTime  updated          = DateTime.ParseExact(vSizeTypeAndDate[2], "yyyyMMddHHmmss", null);

                clips.Add(new MediaInfo(folderName, fileName, type, size, updated));
            }

            device_.OnUpdatedMediafiles(clips);
        }
示例#2
0
        private void OnCLS(AMCPParserEventArgs e)
        {
            List <MediaInfo> clips = new List <MediaInfo>();

            foreach (string mediaInfo in e.Data)
            {
                string pathName   = mediaInfo.Substring(mediaInfo.IndexOf('\"') + 1, mediaInfo.IndexOf('\"', 1) - 1);
                string folderName = "";
                string fileName   = "";

                int delimIndex = pathName.LastIndexOf('/'); // 2.0.7
                if (delimIndex == -1)
                {
                    delimIndex = pathName.LastIndexOf('\\'); // 2.0.6
                }
                if (delimIndex != -1)
                {
                    folderName = pathName.Substring(0, delimIndex);
                    fileName   = pathName.Substring(delimIndex + 1);
                }
                else
                {
                    fileName = pathName;
                }

                string    temp    = mediaInfo.Substring(mediaInfo.LastIndexOf('\"') + 1);
                string[]  param   = temp.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                MediaType type    = (MediaType)Enum.Parse(typeof(MediaType), param[0]);
                Int64     size    = Int64.Parse(param[1]);
                DateTime  updated = DateTime.ParseExact(param[2], "yyyyMMddHHmmss", null);

                string timecode = "";
                if (param.Length > 3)
                {
                    string totalFrames = param[3];
                    string timebase    = param[4];

                    long frames = long.Parse(totalFrames);
                    int  fps    = int.Parse(timebase.Split('/')[1]);

                    double time = frames * (1.0 / fps);
                    timecode = ConvertToTimecode(time, fps);
                }

                clips.Add(new MediaInfo(folderName, fileName, type, size, updated, timecode));
            }

            device_.OnUpdatedMediafiles(clips);
        }