예제 #1
0
        public bool IsMatching(MediaFile src)
        {
            if (this.IsEmpty)
            {
                return(true);
            }
            if (src.MediaType != MediaTypes.Image)
            {
                return(false);
            }
            string     fpath = src.GetFullPath();
            ExifReader xrf   = null;
            ImageDim   dm    = null;
            UInt32?    unz;

            try {
                xrf = new ExifReader(fpath);
                if (this.IsVerticalImg.HasValue)
                {
                    dm = MediaUtil.GetImgDim(xrf);
                    if (this.IsVerticalImg.Value != dm.IsVert)
                    {
                        return(false);
                    }
                }
                if (!IsoFilter.IsEmpty)
                {
                    if (null != (unz = MediaUtil.GetIso(xrf)))
                    {
                        if (!this.IsoFilter.IsMatch(unz.Value))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception x) {
                x.Data["target"] = fpath;
                AppContext.Current.LogTechError(x.ToShortMsg("Read EXIF"), x);
            }
            finally {
                if (xrf != null)
                {
                    xrf.Dispose();
                }
            }
            return(false);
        }
예제 #2
0
        MediaSource CreateMediaSource(string sourcePath)
        {
            MediaSource rz = new MediaSource(this, this.GetNextTrackId());

            rz.Source    = sourcePath;
            rz.MediaType = MediaUtil.GetFileMediaType(sourcePath);
            VideoStreamCfg vCfg;
            AudioStreamCfg aCfg;

            if (this.VHelper.TryGetMetadata(sourcePath, out vCfg, out aCfg))
            {
                if (vCfg != null)
                {
                    rz.Height    = vCfg.Height;
                    rz.Width     = vCfg.Width;
                    rz.DurationS = vCfg.Duration.TotalSeconds;
                }
            }
            return(rz);
        }