Exemple #1
0
        public void GetData(string location)
        {
            try
            {
                ShellObject song = ShellObject.FromParsingName(location);
                nameTextBox.Text    = Index.GetValue(song.Properties.GetProperty(SystemProperties.System.FileName));
                aArtistTextBox.Text = Index.GetValue(song.Properties.GetProperty(SystemProperties.System.Music.AlbumArtist));
                titleTextBox.Text   = Index.GetValue(song.Properties.GetProperty(SystemProperties.System.Title));
                albumTextBox.Text   = Index.GetValue(song.Properties.GetProperty(SystemProperties.System.Music.AlbumTitle));
                yearTextBox.Text    = Index.GetValue(song.Properties.GetProperty(SystemProperties.System.Media.Year));
                lyricsTextBox.Text  = Index.GetValue(song.Properties.GetProperty(SystemProperties.System.Music.Lyrics));

                Shell32.Shell      shell      = new Shell32.Shell();
                Shell32.Folder     objFolder  = shell.NameSpace(System.IO.Path.GetDirectoryName(location));
                Shell32.FolderItem folderItem = objFolder.ParseName(System.IO.Path.GetFileName(location));
                contributingTextBox.Text = objFolder.GetDetailsOf(folderItem, 13);
                genreBox.Text            = objFolder.GetDetailsOf(folderItem, 16);
            }
            catch (ShellException)
            {
                MessageBox.Show("File not found exception!", "Error");
                Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
                Close();
            }
        }
Exemple #2
0
 private void chkRecursive_Checked(object sender, RoutedEventArgs e)
 {
     if (_watcher != null && _watcher.Running)
     {
         StartWatcher(ShellObject.FromParsingName(txtPath.Text));
     }
 }
Exemple #3
0
        public void SetTag(string tag)
        {
            var picture = ShellObject.FromParsingName(_path);
            var strTags = GetValue(picture.Properties.GetProperty(SystemProperties.System.Comment));

            try
            {
                var propertyWriter = picture.Properties.GetPropertyWriter();

                if (strTags == "")
                {
                    propertyWriter.WriteProperty(SystemProperties.System.Comment, tag);
                }
                else
                {
                    propertyWriter.WriteProperty(SystemProperties.System.Comment, strTags + ";" + tag);
                }

                propertyWriter.Close();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
        private TimeSpan GetDuration(string file)
        {
            var tmr    = Stopwatch.StartNew();
            var result = true;

            try
            {
                using (var shell = ShellObject.FromParsingName(file))
                {
                    var prop = shell.Properties.System.Media.Duration;
                    if (prop.ValueAsObject == null)
                    {
                        return(TimeSpan.Zero);
                    }
                    var t = (ulong)prop.ValueAsObject;
                    return(TimeSpan.FromTicks((long)t));
                }
            }
            catch
            {
                result = false;
                return(TimeSpan.Zero);
            }
            finally
            {
                tmr.Stop();
                _logger.Log($"File {file} processed in {tmr.Elapsed}. Result {result}");
            }
        }
        public static double Filelength(string filePath)
        {
            string duration = "";
            double length   = 0;

            try
            {
                string exactPath = Path.GetFullPath(filePath);
                using (ShellObject shell = ShellObject.FromParsingName(exactPath))
                {
                    // alternatively: shell.Properties.GetProperty("System.Media.Duration");
                    IShellProperty prop = shell.Properties.System.Media.Duration;
                    // Duration will be formatted as 00:44:08
                    duration = prop.FormatForDisplay(PropertyDescriptionFormatOptions.None);
                    DateTime.TryParse(duration, out DateTime dateTime);
                    length = dateTime.TimeOfDay.TotalMilliseconds;
                }
            }
            catch (Exception ex)
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("This file doesn't appear to have a file length," +
                                                  " please make sure the file in the json is in the unitity project location.");
            }
            return(length);
        }
        public static string[] GetAllInfo(string filePath)
        {
            using (var shell = ShellObject.FromParsingName(filePath))
            {
                // title
                IShellProperty titleProp = shell.Properties.System.Title;
                var            title     = (string)titleProp.ValueAsObject;

                // artist
                IShellProperty artistProp = shell.Properties.System.Music.DisplayArtist;
                var            artist     = (string)artistProp.ValueAsObject;

                // album
                IShellProperty albumProp = shell.Properties.System.Music.AlbumTitle;
                var            album     = (string)albumProp.ValueAsObject;

                // duration
                IShellProperty durationProp = shell.Properties.System.Media.Duration;
                var            duration     = (ulong)durationProp.ValueAsObject;

                return(new string[]
                {
                    title,
                    artist,
                    album,
                    TimeSpan.FromTicks((long)duration).ToString(@"mm\:ss")
                });
            }
        }
Exemple #7
0
        /*
         * ============================================
         * Private
         * ============================================
         */

        /// <summary>
        /// Get some informations about a file and put them in the view.
        /// </summary>
        private void SetFileInfos(string filepath)
        {
            System.IO.FileInfo info     = new System.IO.FileInfo(filepath);
            ShellObject        shellObj = ShellObject.FromParsingName(filepath);

            // Available properties: https://msdn.microsoft.com/en-us/library/windows/desktop/ff521738(v=vs.85).aspx
            IShellProperty frameRate   = shellObj.Properties.System.Video.FrameRate;
            IShellProperty frameWidth  = shellObj.Properties.System.Video.FrameWidth;
            IShellProperty frameHeight = shellObj.Properties.System.Video.FrameHeight;
            IShellProperty duration    = shellObj.Properties.System.Media.Duration;

            Application.Current.Dispatcher.BeginInvoke((Action)(() => {
                this.Label_Size.Content = "Size: " + (info.Length / 1000000) + "Mo";

                if (frameRate != null && frameRate.ValueAsObject != null)
                {
                    this.Label_Framerate.Content = "Framerate: " + ((uint)frameRate.ValueAsObject * 0.001).ToString() + "FPS";
                }

                if ((frameWidth != null && frameWidth.ValueAsObject != null) && (frameHeight != null && frameHeight.ValueAsObject != null))
                {
                    this.Label_Resolution.Content = "Resolution: " + frameWidth.ValueAsObject.ToString() + "x" + frameHeight.ValueAsObject.ToString();
                }

                if (duration != null)
                {
                    this.Label_Duration.Content = "Duration: " + duration.FormatForDisplay(PropertyDescriptionFormatOptions.None);
                }
            }));
        }
Exemple #8
0
        public static bool IsPlayableVideo(string filepath)
        {
            if (string.IsNullOrEmpty(filepath))
            {
                return(false);
            }
            string extention = Path.GetExtension(filepath).ToLower().Trim('.');

            if (string.IsNullOrEmpty(extention))
            {
                return(false);
            }

            ShellObject obj      = ShellObject.FromParsingName(filepath);
            string      filetype = "";

            filetype = obj.Properties.System.MIMEType.Value;
            if (filetype == null)
            {
                return(false);
            }
            if (filetype.Contains("video"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// Controles of het een volledige radiosessie is
        /// </summary>
        /// <param name="localpath"></param>
        /// <returns></returns>
        private bool IsFullSession(string localpath)
        {
            try
            {
                //Lengte van setje opvragen.
                ulong ticks = 0;
                using (ShellObject shell = ShellObject.FromParsingName(localpath))
                {
                    IShellProperty prop = shell.Properties.System.Media.Duration;
                    if (prop.ValueAsObject is null)
                    {
                        return(false);//Is nog niet compleet
                    }
                    else
                    {
                        ticks = (ulong)prop.ValueAsObject;
                    }
                }

                //Kijken of het een volledige sessie is
                if (ticks > 108000000000) //3 uur lengte
                {
                    return(true);         //Het is een volledige sessie.
                }

                return(false);//De sessie is nog niet compleet
            }
            catch (Exception ex)
            {
                Console.WriteLine("GetLengthUsingShellObject failed: " + ex.Message);

                return(false);//Er is iets misgelopen, de sessie is waarschijnlijk niet compleet
            }
        }
 public TimeSpan?GetDuration(string filePath)
 {
     try
     {
         using (ShellObject shell = ShellObject.FromParsingName(filePath))
         {
             IShellProperty prop  = shell.Properties.System.Media.Duration;
             var            value = prop.ValueAsObject;
             return(TimeSpan.FromTicks((long)(ulong)value));
             // Duration will be formatted as 00:44:08
             //string duration = prop.FormatForDisplay(PropertyDescriptionFormatOptions.None);
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e);
         try
         {
             IWMPMedia mediainfo = _wmp.newMedia(filePath);
             var       duration  = mediainfo.duration;
             if (duration < double.Epsilon)
             {
                 return(null);
             }
             return(TimeSpan.FromSeconds(duration));
         }
         catch (Exception e2)
         {
             Debug.WriteLine(e);
             return(null);
         }
         return(null);
     }
 }
        static void Main(string[] args)
        {
            var rootFolderPath = GetFolderPath();
            //var folderPath = "D:\\Users\\zhangyuan\\Desktop\\120_FUJI";

            var filePaths = Directory.GetFiles(rootFolderPath);

            //Dictionary<string, DateTime> dicFileDate = new Dictionary<string, DateTime>();

            foreach (var filePath in filePaths)
            {
                ShellObject obj       = ShellObject.FromParsingName(filePath);
                var         takenDate = obj.Properties.System.ItemDate.Value;
                if (takenDate.HasValue)
                {
                    string folderPath = rootFolderPath + "\\" + takenDate.Value.ToString("yyyy-MM-dd");
                    if (!Directory.Exists(folderPath))
                    {
                        Directory.CreateDirectory(folderPath);
                    }

                    FileInfo file = new FileInfo(filePath);
                    file.MoveTo(folderPath + "\\" + file.Name);
                }
            }

            Console.WriteLine("OK");
            Console.ReadLine();
        }
Exemple #12
0
        public override bool RunBody(State state)
        {
            RequirePropertyHandlerRegistered();
            RequireExtHasHandler();

            const string cval         = "bcomment??";
            string       propertyName = "System.Comment";

            //Create a temp file to put metadata on
            string fileName = CreateFreshFile(1);

            var handler = new CPropertyHandler();

            handler.Initialize(fileName, 0);

            PropVariant value = new PropVariant(cval);

            handler.SetValue(new TestDriverCodePack.PropertyKey(new Guid("F29F85E0-4FF9-1068-AB91-08002B27B3D9"), 6), value);
            handler.Commit();

            Marshal.ReleaseComObject(handler);  // preempt GC for CCW

            // Use API Code Pack to read the value
            IShellProperty prop = ShellObject.FromParsingName(fileName).Properties.GetProperty(propertyName);
            object         oval = prop.ValueAsObject;

            File.Delete(fileName);  // only works if all have let go of the file

            return((string)oval == cval);
        }
Exemple #13
0
        public AbstractMediaMetaData Extract(string filePath)
        {
            var fi = new FileInfo(filePath);

            if (!fi.Exists)
            {
                return(null);
            }

            using (var video = ShellObject.FromParsingName(filePath))
            {
                var duration = video.Properties.GetProperty <ulong?>(SystemProperties.System.Media.Duration).Value;

                return(new VideoMetaData
                {
                    FilePath = filePath,
                    DateCreatedUtc = fi.CreationTimeUtc,
                    Name = GetStringValue(video.Properties, SystemProperties.System.Title),
                    DurationSeconds = duration == null ? 0 : (int)(duration.Value / 1E+7),
                    Height = GetIntegerValue(video.Properties, SystemProperties.System.Video.FrameHeight),
                    Width = GetIntegerValue(video.Properties, SystemProperties.System.Video.FrameWidth), SizeBytes = fi.Length,
                    AudioChannels = GetIntegerValue(video.Properties, SystemProperties.System.Audio.ChannelCount),
                    AudioBitrate = (int)(GetIntegerValue(video.Properties, SystemProperties.System.Audio.EncodingBitrate) / (double)1000),
                    AudioIsVariableBitrate = GetBoolValue(video.Properties, SystemProperties.System.Audio.IsVariableBitrate),
                    AudioSampleRate = GetIntegerValue(video.Properties, SystemProperties.System.Audio.SampleRate) / (double)1000,
                    AudioBitsPerSample = GetIntegerValue(video.Properties, SystemProperties.System.Audio.SampleSize),
                    VideoDataRate = GetIntegerValue(video.Properties, SystemProperties.System.Video.EncodingBitrate) / (double)1000,
                    VideoTotalBitrate = GetIntegerValue(video.Properties, SystemProperties.System.Video.TotalBitrate) / (double)1000,
                    VideoFrameRate = GetIntegerValue(video.Properties, SystemProperties.System.Video.FrameRate) / (double)1000,
                    Copyright = GetStringValue(video.Properties, SystemProperties.System.Copyright),
                });
            }
        }
Exemple #14
0
        private void OpenFileButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog
            {
                InitialDirectory = @"C:\",
                Title            = "Browse Files",

                CheckFileExists = true,
                CheckPathExists = true,

                DefaultExt       = "txt",
                Filter           = "All files (*.*)|*.*",
                FilterIndex      = 2,
                RestoreDirectory = true,

                ReadOnlyChecked = true,
                ShowReadOnly    = true
            };

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string filepath = openFileDialog1.FileName;
                FilePathTextbox.Text = filepath;

                myFile = ShellObject.FromParsingName(filepath);

                GetFileProperties();
            }
        }
        private void ShareWizzard_Load(object sender, EventArgs e)
        {
            ShellObject sho = ShellObject.FromParsingName(CurrentPath);

            txtShareName.Text = sho.GetDisplayName(Microsoft.WindowsAPICodePack.Shell.DisplayNameType.Default);
            sho.Dispose();
        }
        /// <summary>
        /// Gets the duration as nano seconds.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        /// <returns></returns>
        public static long GetDurationAsNanoSeconds(string filePath)
        {
            Logger.Info("DurationProvier:GetDurationAsNanoSeconds", "Calculating video file duration");
            long duration;

            try
            {
                using (ShellObject shell = ShellObject.FromParsingName(filePath))
                {
                    IShellProperty prop = shell.Properties.System.Media.Duration; // in 100-nanoseconds unit
                    if (prop == null || prop.ValueAsObject == null)
                    {
                        return(0);
                    }
                    string nb = prop.ValueAsObject.ToString();
                    if (long.TryParse(nb, out duration))
                    {
                        return(duration * 100);
                    }
                }
            }
            catch (Exception exception)
            {
                Logger.Error("DurationProvier:GetDurationAsNanoSeconds", "Unable to calculate file duration: " + exception.Message);
            }
            return(0);
        }
Exemple #17
0
        private static ReadOnlyCollection <FileProperty> GetFileProperties(string fileName)
        {
            //var camera = GetValue(picture.Properties.GetProperty(SystemProperties.System.Photo.CameraModel));
            //var company = GetValue(picture.Properties.GetProperty(SystemProperties.System.Photo.CameraManufacturer));

            var properties = new List <FileProperty>();

            using (ShellObject shellObject = ShellObject.FromParsingName(fileName))
            {
                foreach (var shellProperty in shellObject.Properties.DefaultPropertyCollection)
                {
                    string value = GetValue(shellProperty);
                    if (string.IsNullOrEmpty(value) || shellProperty.CanonicalName == null)
                    {
                        continue;
                    }

                    properties.Add(new FileProperty(
                                       shellProperty.CanonicalName,
                                       shellProperty.Description.DisplayName,
                                       GetValue(shellProperty)
                                       )
                                   );
                }
            }

            properties.Sort((x, y) => string.CompareOrdinal(x.CanonicalName, y.CanonicalName));

            return(properties.AsReadOnly());
        }
Exemple #18
0
        public static Icon Extracticonfile(String namefile)
        {
            var            shell = ShellObject.FromParsingName(namefile);
            ShellThumbnail sh    = shell.Thumbnail;

            return(sh.MediumIcon);
        }
        public static string[] GetDetails(string filePath)
        {
            using (var shell = ShellObject.FromParsingName(filePath))
            {
                // compression
                IShellProperty compressionProp = shell.Properties.System.Audio.Compression;
                var            compression     = (string)compressionProp.ValueAsObject;

                // bitrate
                IShellProperty bitrateProp = shell.Properties.System.Audio.EncodingBitrate;
                var            bitrate     = (uint)bitrateProp.ValueAsObject;

                // bpm
                IShellProperty bpmProp = shell.Properties.System.Music.BeatsPerMinute;
                var            bpm     = (string)bpmProp.ValueAsObject;

                // released
                IShellProperty releasedProp = shell.Properties.System.Media.DateReleased;
                var            released     = (string)releasedProp.ValueAsObject;

                // duration
                IShellProperty durationProp = shell.Properties.System.Media.Duration;
                var            duration     = (ulong)durationProp.ValueAsObject;

                return(new string[]
                {
                    compression,
                    (bitrate / 1000).ToString(),
                    bpm,
                    released,
                    TimeSpan.FromTicks((long)duration).ToString(@"mm\:ss")
                });
            }
        }
        static void DisplaySelectedProperties(string path, string[] paramStrings, string extensions)
        {
            DirectoryInfo          dir   = new DirectoryInfo(path);
            IEnumerable <FileInfo> files = dir.GetFiles().Where(f => extensions.Contains(f.Extension) || extensions == "");

            Console.Write("File Name");

            foreach (var param in paramStrings)
            {
                Console.Write("|" + param);
            }

            Console.Write("\n");

            foreach (var file in files)
            {
                Console.Write(file.Name);

                using (var shell = ShellObject.FromParsingName(file.FullName))
                {
                    foreach (var param in paramStrings)
                    {
                        Console.Write("|");

                        if (shell.Properties.DefaultPropertyCollection.Contains(param))
                        {
                            Console.Write(shell.Properties.GetProperty(param).ValueAsObject.ToString());
                        }
                    }

                    Console.Write("\n");
                }
            }
        }
Exemple #21
0
        public static Dictionary <string, string> GetAppProperties(string filePath1)
        {
            Dictionary <string, string> AppProperties = new Dictionary <string, string>();

            ShellObject shellFile = ShellObject.FromParsingName(filePath1);

            foreach (var property in typeof(ShellProperties.PropertySystem).GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                IShellProperty shellProperty = property.GetValue(shellFile.Properties.System, null) as IShellProperty;
                if (shellProperty?.ValueAsObject == null)
                {
                    continue;
                }
                if (AppProperties.ContainsKey(property.Name))
                {
                    continue;
                }

                string[] shellPropertyValues = shellProperty.ValueAsObject as string[];

                if (shellPropertyValues != null && shellPropertyValues.Length > 0)
                {
                    foreach (string shellPropertyValue in shellPropertyValues)
                    {
                        AppProperties[property.Name] = shellPropertyValue.ToString();
                    }
                }
                else
                {
                    AppProperties[property.Name] = shellProperty.ValueAsObject.ToString();
                }
            }

            return(AppProperties);
        }
        private void RequestNavigation(String Path)
        {
            PathEventArgs       ea   = null;
            var                 path = String.Empty;
            BreadcrumbBarFSItem item = null;

            if (Path.Trim().StartsWith("%"))
            {
                path = Environment.ExpandEnvironmentVariables(Path);
                item = new BreadcrumbBarFSItem(Path, path);
            }
            else
            {
                path = Path;
                item = new BreadcrumbBarFSItem(ShellObject.FromParsingName(Path.StartsWith(":") ? "shell:" + Path : Path));
            }

            ea = new PathEventArgs(ShellObject.FromParsingName(path));

            OnNavigateRequested(ea);
            if (writetohistory == true)
            {
                if (hl.Select(s => s.RealPath).Contains(Path) == false)
                {
                    hl.Add(item);
                }
            }
        }
Exemple #23
0
        public static Icon Extrfile(String namefile)
        {
            var            shell = (ShellFile)ShellObject.FromParsingName(namefile);
            ShellThumbnail sh    = shell.Thumbnail;

            return(sh.Icon);
        }
Exemple #24
0
        private string GetMediaTitle(VideoFolderChild vd)
        {
            ShellObject shell = ShellObject.FromParsingName(vd.FilePath);

            try
            {
                var duration = shell.Properties.System.Media.Duration;
                vd.Duration = duration.FormatForDisplay(PropertyDescriptionFormat.ShortTime);
                //if (duration.Value != null)
                //    vd.MaxiProgress = (int)(duration.Value / Math.Pow(10, 7));
            }
            catch (Exception ex)
            {
            }

            //MediaInfo.MediaInfoWrapper mediaInfoWrapper = new MediaInfo.MediaInfoWrapper(vd.FullName);
            //string result = null;
            //if (mediaInfoWrapper.HasVideo)
            //{
            //    //Dispatcher.Invoke(new Action(() => {
            //    // mediaInfoWrapper.Open(vd.FullName);
            //    //result = mediaInfoWrapper.Get(MediaInfo.StreamKind.General, 0, 167);
            //    result = (mediaInfoWrapper.Tags as AudioTags).Title;
            //    vd.MaxiProgress = mediaInfoWrapper.Duration;
            //    vd.Duration = mediaInfoWrapper.BestVideoStream.Duration.ToString();
            //}
            //mediaInfoWrapper.Close();
            //}),DispatcherPriority.Background);

            return(shell.Properties.System.Title.Value);
        }
Exemple #25
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            if (_args.Length > 0)
            {
                try
                {
                    string newPath = _args[0];

                    if (Directory.Exists(newPath))
                    {
                        UserControlExplorer curUCE = AddExplorer(tabControl1, "", true);
                        tabControl1.SelectedIndex = tabControl1.TabCount - 2;

                        if (curUCE != null)
                        {
                            curUCE.explorerBrowser.Navigate(ShellObject.FromParsingName(newPath));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
        }
Exemple #26
0
        private static void GetMediaInfo(VideoFolderChild vd)
        {
            ShellObject shell = ShellObject.FromParsingName(vd.FilePath);

            try
            {
                vd.Thumbnail = shell.Thumbnail.LargeBitmapSource;
                if (string.IsNullOrEmpty(vd.Duration) || vd.Duration == ApplicationDummyMessage.DurationNotYetLoaded)
                {
                    var duration = shell.Properties.System.Media.Duration;
                    vd.Duration = duration.FormatForDisplay(PropertyDescriptionFormat.ShortTime);
                }
                //if (duration.Value != null)
                //    vd.MaxiProgress = (int)(duration.Value / Math.Pow(10, 7));
            }
            catch (Exception ex)
            {
            }
            var prop = shell.Properties.System.Title.Value;

            if (!string.IsNullOrEmpty(prop) && !prop.Contains("\""))
            {
                vd.MediaTitle = prop;
            }
        }
Exemple #27
0
        public bool Load()
        {
            bool flg = true;

            try
            {
                FileStream             fs   = new FileStream(SaveFileName, FileMode.Open, FileAccess.Read);
                DataContractSerializer s    = new DataContractSerializer(typeof(DatSaveInfo));
                DatSaveInfo            info = (DatSaveInfo)s.ReadObject(fs);
                fs.Close();

                foreach (string path in info.Path)
                {
                    TabItemUI ti = this.CreateTabItem(ShellObject.FromParsingName(path));
                    this.tabControl.Items.Add(ti);
                }
                this.tabControl.SelectedIndex = info.SelectedIndex;
                foreach (KeyValuePair <string, string> kv in info.BookMarks)
                {
                    this.BookMarks.Add(kv);
                }
            }
            catch (Exception)
            {
                flg = false;
            }

            return(flg);
        }
Exemple #28
0
        public ImageSource GetImageFromAlbumArtProperty(string path)
        {
            ShellObject shellFile          = ShellObject.FromParsingName(path);
            Bitmap      thumbnailFromShell = shellFile.Thumbnail.LargeBitmap;

            return(thumbnailFromShell.BitmapToImageSource());
        }
Exemple #29
0
        private IList <Video> GetVideoesByLabel(Label label)
        {
            string videoPath = $"input/video/{label.Name}_video";

            string[] files = Directory.GetFiles(videoPath, "*.mp4");
            if (files.Length == 0)
            {
                Logger.Throw($"Not exist {label.Name} video files");
            }

            var videoes = new List <Video>();

            foreach (string file in files)
            {
                using (ShellFile shellFile = ShellFile.FromFilePath(file))
                    using (ShellObject shell = ShellObject.FromParsingName(shellFile.Path))
                    {
                        IShellProperty prop        = shell.Properties.System.Media.Duration;
                        string         durationStr = prop.FormatForDisplay(PropertyDescriptionFormatOptions.None);

                        int      fps      = (int)shellFile.Properties.System.Video.FrameRate.Value.Value / 1000;
                        TimeSpan duration = TimeSpan.Parse(durationStr);

                        IList <Meta> metas = GetMetasByVideo(label,
                                                             Path.GetFileNameWithoutExtension(file));

                        Video video = new Video(file, fps, duration, metas);

                        videoes.Add(video);
                    }
            }

            return(videoes);
        }
Exemple #30
0
        static void ReadProperties(string file, Options o)
        {
            if (!File.Exists(file))
            {
                return;
            }

            var data = new Data();

            if (o.All)
            {
                foreach (var prop in new ShellPropertyCollection(file))
                {
                    data.Add(prop);
                }
            }
            else
            {
                var props = ShellObject.FromParsingName(file).Properties;
                data.Add(props.System.Keywords);
                data.Add(props.System.Comment);
            }

            var xmlFile = file + ".props.xml";

            using (TextWriter writer = new StreamWriter(xmlFile))
            {
                data.Serializer.Serialize(writer, data);
            }

            if (o.Verbose)
            {
                Console.WriteLine($"Wrote properties of {file} to {xmlFile}");
            }
        }