Пример #1
0
        void addTrySelect(FileInfo fi)
        {
            var mu = MediaUnit.LoadMetaData(fi.FullName);

            _MediaUnits.Add(mu);
            if (string.Compare(mu.PathFileCur, _CurFile, true) == 0)
            {
                _CurIndx = _MediaUnits.Count;
            }
        }
Пример #2
0
        static MediaUnit loadMetaDataFromMediaFile(string media, TimeSpan?duration = null, int?NaturalVideoHeight = null, int?NaturalVideoWidth = null)
        {
            var mdfn = metadataFilename(media);

            MediaUnit mu;

            if (File.Exists(mdfn))
            {
                mu          = Serializer.LoadFromFile <MediaUnit>(mdfn) as MediaUnit;
                mu.Position = TimeSpan.FromSeconds(mu.PositionSec);
                mu.Duration = TimeSpan.FromSeconds(mu.DurationSec);
            }
            else
            {
                mu = new MediaUnit {
                    PathFileCur = media
                };
            }

            checkMpcViewTime(media, mu);

            if (duration != null && duration.HasValue)
            {
                mu.Duration = duration.Value;
            }
            if (NaturalVideoHeight != null)
            {
                mu.VideoHeight = NaturalVideoHeight.Value;
            }
            if (NaturalVideoWidth != null)
            {
                mu.VideoWidth = NaturalVideoWidth.Value;
            }

            if (mu.AddedAt == DateTime.MinValue)
            {
                mu.AddedAt = new FileInfo(media).LastWriteTime;
            }
            if (mu.FileLength == 0)
            {
                mu.FileLength = new FileInfo(media).Length;
            }

            if (string.IsNullOrEmpty(mu.PathFileCur) || mu.PathFileCur != media)
            {
                mu.PathFileCur = media;
            }
            if (string.IsNullOrEmpty(mu.PathFileOrg))
            {
                mu.PathFileOrg = media;
            }

            return(mu);
        }
Пример #3
0
        public static void SaveMetaData_ALWAYS(MediaUnit mu)
        {
            var mdfn = metadataFilename(mu.PathFileCur);

            Serializer.SaveToFile(mu, mdfn);

            setMediaPlayerCalssicPositionInSec(mu.PathFileCur, mu.PositionSec);

            ///todo: in order to get proper start time implement
            ///set-version of getMediaPlayerCalssicPositionInSec(media); ...
            ///... or maybe remove completely from MPC
        }
Пример #4
0
        static void checkMpcViewTime(string media, MediaUnit mu)
        {
            var mpc = getMediaPlayerCalssicPositionInSec(media);

            if (mpc > mu.PositionSec)
            {
                if (mu.PositionSec == 0)
                {
                    ViewTimeLog.Log(TimeSpan.FromSeconds(mpc));
                }
                mu.Position = TimeSpan.FromSeconds(mu.PositionSec = mpc);
            }
        }
Пример #5
0
        public static void SaveMetaData(MediaUnit mu)
        {
            const int minLengthWorthSaving = 600;

            if (IsAudio(mu.FileName))
            {
                if (mu.DurationSec < minLengthWorthSaving && (mu.Duration.TotalSeconds < minLengthWorthSaving))
                {
                    return;
                }
            }

            SaveMetaData_ALWAYS(mu);
        }