Beispiel #1
0
        /// <summary>
        /// Converts IVideoProperties to string.
        /// </summary>
        /// <param name="props">The props.</param>
        /// <returns></returns>
        public static string IVideoPropertiesToString(IVideoProperties props)
        {
            string resPrefix = string.Empty;
            string resSuffix = string.Empty;
            string res       = string.Empty;

            if (props.Duration.HasValue && props.Duration.Value > 0)
            {
                TimeSpan dur = (new TimeSpan(0, 0, 0, 0, (int)props.Duration.Value));
                //res += dur.ToString().Split('.')[0];
                res      += dur.Hours + "h " + dur.Minutes + "m " + dur.Seconds + "s";
                resPrefix = " (";
                resSuffix = ")";
            }
            if (props.Width.HasValue && props.Height.HasValue)
            {
                res += resPrefix + props.Width.Value + "x" + props.Height.Value + resSuffix;
            }
            if (props.Format != string.Empty)
            {
                res += " - " + props.Format;
                if (props.BitRate.HasValue)
                {
                    res += " (" + (props.Encoding != string.Empty ? props.Encoding + " @ " : string.Empty) + GetBitRateString(props.BitRate.Value) + ")";
                }
            }

            return(res);
        }
Beispiel #2
0
        public async Task LoadAsync()
        {
            if (!await _videoReader.OpenAsync(VideoUrl))
            {
                throw new Exception($"Open video \"{VideoUrl}\" failed.");
            }

            _videoProperties  = _videoReader.Properties;
            _stopByTargetTime = 0.0;
            _state            = State.StopBy;

            _backgroundWorker.RunWorkerAsync();
        }