Inheritance: IVideoProperties, IStorageItemExtraProperties
示例#1
0
        public async Task <bool> loadVideoProps()
        {
            if (String.IsNullOrEmpty(this.fileInfo.FullName))
            {
                return(false);
            }

            StorageFile file = await StorageFile.GetFileFromPathAsync(this.fileInfo.FullName);

            Windows.Storage.FileProperties.VideoProperties videoProperties = await file.Properties.GetVideoPropertiesAsync();

            Windows.UI.Xaml.Duration videoDuration = videoProperties.Duration;
            this.duration = videoDuration.ToString();
            return(true);
        }
示例#2
0
        public static void FillVideoProperties(PropertiesFlyoutVideo flyout, VideoProperties videoProps)
        {
            try
            {
                if (!string.IsNullOrEmpty(videoProps.Title))
                    flyout.VideoTitle.Text = videoProps.Title;
                else if (!string.IsNullOrEmpty(videoProps.Subtitle))
                    flyout.VideoTitle.Text = videoProps.Subtitle;
                else
                    flyout.HideVideoTitle();

                if (videoProps.Duration.TotalSeconds > 0)
                    flyout.Duration.Text = TimeSpan_ToString(videoProps.Duration);
                else
                    flyout.HideDuration();

                if (videoProps.Directors.Count >= 1)
                    flyout.Directors.Text += NameCreditsStr("", videoProps.Directors);
                else
                    flyout.HideDirectors();

                if (videoProps.Writers.Count >= 1)
                    flyout.Writers.Text = NameCreditsStr("", videoProps.Writers);
                else
                    flyout.HideWriters();

                if (videoProps.Producers.Count >= 1)
                    flyout.Producers.Text = NameCreditsStr("", videoProps.Producers);
                else
                    flyout.HideProducers();

                if (!string.IsNullOrEmpty(videoProps.Publisher))
                    flyout.Publisher.Text = videoProps.Publisher;
                else
                    flyout.HidePublisher();

                if (videoProps.Width > 0 && videoProps.Height > 0)
                    flyout.Dimensions.Text = videoProps.Width.ToString() + " x " + videoProps.Height.ToString() + " pixels";
                else
                    flyout.HideDimensions();

                if (videoProps.Year > 0)
                    flyout.Year.Text = videoProps.Year.ToString();
                else
                    flyout.HideYear();

                if (videoProps.Rating > 0)
                {
                    uint starRating = (videoProps.Rating == 0) ? 0 : (uint)Math.Round((double)videoProps.Rating / 25.0) + 1;
                    flyout.Rating.Text = starRating.ToString() + "*";
                }
                else
                    flyout.HideRating();

                if (videoProps.Bitrate > 0)
                    flyout.Bitrate.Text = Util.NumberToString(videoProps.Bitrate, "bps");
                else
                    flyout.HideBitrate();

                if (videoProps.Keywords.Count >= 1)
                    flyout.Keywords.Text = NameCreditsStr("", videoProps.Keywords);
                else
                    flyout.HideKeywords();

                // IMPORTANT: Need GeoCoordinate class from System.Device.Location namespace (but not avail on WinRT);
                // Not suitable: Windows.Devices.Geolocation namespace;
                // GeoCoordinate geoCoord = new GeoCoordinate();
                if (videoProps.Latitude.HasValue)
                    flyout.Latitude.Text = Util.LatOrLong_ToString(videoProps.Latitude);
                else
                    flyout.HideLatitude();
                if (videoProps.Longitude.HasValue)
                    flyout.Longitude.Text = Util.LatOrLong_ToString(videoProps.Longitude);
                else
                    flyout.HideLongitude();
            }
            catch (Exception ex) { Debug.WriteLine(ex.ToString()); }
        }
        private static void GetVideoProperties(ICollection<StorageFileProperty> results, VideoProperties props)
        {
            var title = props.Title;
            var subTitle = props.Subtitle;
            var duration = props.Duration;
            var bitRate = props.Bitrate;
            var height = props.Height;
            var width = props.Width;

            var latitude = props.Latitude.ToString();
            var longitude = props.Longitude.ToString();

            if (!title.IsEmpty())
            {
                if (results.FirstOrDefault(x => x.Name == "Title") == null)
                {
                    results.Add(new StorageFileProperty("Title", title));
                }
            }

            if (!subTitle.IsEmpty())
            {
                if (results.FirstOrDefault(x => x.Name == "Subtitle") == null)
                {
                    results.Add(new StorageFileProperty("Subtitle", subTitle));
                }
            }

            if (duration != TimeSpan.FromSeconds(0))
            {
                var val = duration.ToString("G");
                if (!val.IsEmpty())
                {
                    if (results.FirstOrDefault(x => x.Name == "Duration") == null)
                    {
                        results.Add(new StorageFileProperty("Duration", val));
                    }
                }
            }

            if (bitRate != 0)
            {
                if (results.FirstOrDefault(x => x.Name == "Bitrate") == null)
                {
                    results.Add(new StorageFileProperty("Bitrate", bitRate));
                }
            }

            if (height != 0 || width != 0)
            {
                if (results.FirstOrDefault(x => x.Name == "Height") == null)
                {
                    results.Add(new StorageFileProperty("Height", height));
                }

                if (results.FirstOrDefault(x => x.Name == "Width") == null)
                {
                    results.Add(new StorageFileProperty("Width", width));
                }
            }

            if (!latitude.IsEmpty())
            {
                if (results.FirstOrDefault(x => x.Name == "GPS latitude") == null)
                {
                    results.Add(new StorageFileProperty("GPS latitude", latitude));
                }
            }

            if (!longitude.IsEmpty())
            {
                if (results.FirstOrDefault(x => x.Name == "GPS longitude") == null)
                {
                    results.Add(new StorageFileProperty("GPS longitude", longitude));
                }
            }
        }