/// <summary> /// 获取MD5和播放时长 /// </summary> /// <param name="FilePathName"></param> /// <returns></returns> public ViewModelVideoItem GetItem(string FilePathName) { ViewModelVideoItem newItem = new ViewModelVideoItem(); newItem.Name = FilePathName.Substring(FilePathName.LastIndexOf("\\") + 1); newItem.ReRelativeUrl = FilePathName; int sum = 0; if (newItem.Name.Substring(newItem.Name.LastIndexOf(".")) == ".wmv" || newItem.Name.Substring(newItem.Name.LastIndexOf(".")) == ".WMV") { Shell32.Shell shell = new Shell32.Shell(); Shell32.Folder folder = shell.NameSpace(FilePathName.Substring(0, FilePathName.LastIndexOf("\\"))); Shell32.FolderItem folderitem = folder.ParseName(newItem.Name); string len; if (Environment.OSVersion.Version.Major >= 6) { len = folder.GetDetailsOf(folderitem, 27); } else { len = folder.GetDetailsOf(folderitem, 21); } string[] str = len.Split(new char[] { ':' }); sum = int.Parse(str[0]) * 3600 + int.Parse(str[1]) * 60 + int.Parse(str[2]) + 1; } newItem.SunTime = sum; newItem.MD5Value = SeatManage.SeatManageComm.SeatComm.GetMD5HashFromFile(newItem.ReRelativeUrl); return(newItem); }
/// <summary> /// 插入播放文件 /// </summary> public void LoopInsertPlayFile(ViewModelVideoItem item, int index) { string functionName = "LoopInsertPlayFile"; try { ViewModelVideoItem newItem = new ViewModelVideoItem(); newItem.Name = item.Name; newItem.PlayTime = item.PlayTime; newItem.ReRelativeUrl = item.Name; newItem.MD5Value = item.MD5Value; if (item.Name.Substring(item.Name.LastIndexOf(".")) == ".wmv" || item.Name.Substring(item.Name.LastIndexOf(".")) == ".WMV") { newItem.SunTime = item.SunTime; } else { newItem.SunTime = GetImagePlayTime(index); } PlayFileList.Insert(index, newItem); } catch (AMS.Model.CustomerException ex) { ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction); } catch (Exception ex) { ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName); } }
/// <summary> /// 添加新的媒体文件 /// </summary> public void AddNewMediaFile(ViewModelVideoItem itemFile) { string functionName = "AddNewMediaFile"; try { bool isNew = true; foreach (ViewModelVideoItem item in MediaFileList) { if (item.MD5Value == itemFile.MD5Value) { isNew = false; break; } } if (isNew) { MediaFileList.Add(itemFile); } } catch (AMS.Model.CustomerException ex) { ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction); } catch (Exception ex) { ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName); } }
public ViewModelPlayListEditWindow() { _PlayListModel = new Model.AMS_PlayList(); MediaFileList.Clear(); PlayFileList.Clear(); foreach (AMS.Model.AMS_VideoItem item in _PlayListModel.MediaFiles) { ViewModelVideoItem newItem = new ViewModelVideoItem(); newItem.Name = item.Name; newItem.PlayTime = item.PlayTime; newItem.ReRelativeUrl = item.ReRelativeUrl; newItem.SunTime = item.SunTime; newItem.MD5Value = item.MD5Value; MediaFileList.Add(newItem); } foreach (AMS.Model.AMS_VideoItem item in _PlayListModel.PlayFileList) { ViewModelVideoItem newItem = new ViewModelVideoItem(); newItem.Name = item.Name; newItem.PlayTime = item.PlayTime; newItem.ReRelativeUrl = item.ReRelativeUrl; newItem.SunTime = item.SunTime; newItem.MD5Value = item.MD5Value; PlayFileList.Add(newItem); } }
public void RefreshModel() { string functionName = "RefreshModel"; try { MediaFileList.Clear(); PlayFileList.Clear(); foreach (AMS.Model.AMS_VideoItem item in _PlayListModel.MediaFiles) { ViewModelVideoItem newItem = new ViewModelVideoItem(); newItem.Name = item.Name; newItem.PlayTime = item.PlayTime; newItem.ReRelativeUrl = item.ReRelativeUrl; newItem.SunTime = item.SunTime; newItem.MD5Value = item.MD5Value; MediaFileList.Add(newItem); } foreach (AMS.Model.AMS_VideoItem item in _PlayListModel.PlayFileList) { ViewModelVideoItem newItem = new ViewModelVideoItem(); newItem.Name = item.Name; newItem.PlayTime = item.PlayTime; newItem.ReRelativeUrl = item.ReRelativeUrl; newItem.SunTime = item.SunTime; newItem.MD5Value = item.MD5Value; PlayFileList.Add(newItem); } StartH = DateTime.Parse(_PlayListModel.PlayFileList[0].PlayTime).Hour; StartM = DateTime.Parse(_PlayListModel.PlayFileList[0].PlayTime).Minute; RefreshPlayList(); RefreshFileList(); OnPropertyChanged("PlayeListNo"); OnPropertyChanged("PlayerListName"); OnPropertyChanged("EffectDate"); OnPropertyChanged("EndDate"); OnPropertyChanged("Operator"); } catch (AMS.Model.CustomerException ex) { ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction); } catch (Exception ex) { ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName); } }