计算加速文件中的播放秒数

本文关键字:播放 加速 文件 计算 | 更新日期: 2023-09-27 17:53:46

我有一个原始文件。然后加速X%我需要计算加速文件中的秒数。例如,原始文件中的5秒=加速文件中的x秒。这是我的代码:

 private static TimeSpan GetSpeedUpTime(double seconds)
        {
            var time = new TimeSpan(0, 0, (int)Math.Floor(seconds));
            int increaseSpeedValue;
            int.TryParse(ConfigurationManager.AppSettings["IncreaseSpeedValue"], out increaseSpeedValue);
            return new TimeSpan(0, 0, (int)Math.Floor(seconds * increaseSpeedValue / 100));
        }

我不明白我做错了什么?我知道这个任务很简单……但无法在一小时内解决…

计算加速文件中的播放秒数

increaseSpeedValue / 100将作为整数除法处理。请参阅此处的备注部分。这将把TimeSpan设置为错误。

解决方案是转换为(double)或简单地写100.0