public static ObservableCollection <VideoFolder> LoadChildrenFiles(IFolder Parentdir, bool newpath = false) { ObservableCollection <VideoFolder> Toparent = new ObservableCollection <VideoFolder>(); List <FileInfo> files = FileExplorerCommonHelper.GetFilesByExtensions(Parentdir.Directory, formats); if (files.Count > 0) { ApplicationService.CreateLastSeenFolder(Parentdir); ApplicationService.LoadLastSeenFile(Parentdir); } for (int i = 0; i < files.Count; i++) { VideoFolderChild vd; PlayedFiles pdf = (PlayedFiles)LastSeenHelper.GetProgress(Parentdir, files[i].Name); vd = new VideoFolderChild(Parentdir, files[i]) { FileSize = FileExplorerCommonHelper.FileSizeConverter(files[i].Length), FileType = FileType.File }; if (pdf != null) { vd.LastPlayedPoisition = pdf; } else { vd.LastPlayedPoisition = new PlayedFiles(files[i].Name); } Toparent.Add(vd); } return(Toparent); }
public static VideoFolder LoadChildrenFiles(DirectoryInfo directoryInfo, bool newpath = false) { IFolder Parentdir = new VideoFolder(directoryInfo.Parent.FullName); ApplicationService.CreateLastSeenFolder(Parentdir); ApplicationService.LoadLastSeenFile(Parentdir); FileInfo fileInfo = new FileInfo(directoryInfo.FullName); VideoFolderChild vd; PlayedFiles pdf = (PlayedFiles)LastSeenHelper.GetProgress(Parentdir, fileInfo.Name); vd = new VideoFolderChild(Parentdir, fileInfo) { FileSize = FileExplorerCommonHelper.FileSizeConverter(fileInfo.Length), FileType = FileType.File }; if (pdf != null) { vd.LastPlayedPoisition = pdf; } else { vd.LastPlayedPoisition = new PlayedFiles(fileInfo.Name); } IEnumerable <FileInfo> files = null; using (ShellObject shell = ShellObject.FromParsingName(vd.FilePath)) { IShellProperty prop = shell.Properties.System.Media.Duration; vd.Duration = prop.FormatForDisplay(PropertyDescriptionFormat.ShortTime); var duration = shell.Properties.System.Media.Duration; if (duration.Value != null) { vd.MaxiProgress = double.Parse(duration.Value.ToString()); } files = FileExplorerCommonHelper.GetSubtitleFiles(directoryInfo.Parent); } vd.SubPath = FileExplorerCommonHelper.MatchSubToMedia(vd.Name, files); return(vd); }