C# 计算加速文件中的播放秒数
我有一份原始文件。然后,我把它加速到X%。我需要计算加速文件中的秒数。例如,原始文件中的5秒=加速文件中的x秒。这是我的代码:C# 计算加速文件中的播放秒数,c#,C#,我有一份原始文件。然后,我把它加速到X%。我需要计算加速文件中的秒数。例如,原始文件中的5秒=加速文件中的x秒。这是我的代码: private static TimeSpan GetSpeedUpTime(double seconds) { var time = new TimeSpan(0, 0, (int)Math.Floor(seconds)); int increaseSpeedValue; int
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));
}
我不明白我做错了什么?我知道这项任务很简单。。。但无法在一小时内解决它…此
递增速度值/100
将作为整数除法处理。。这会将时间跨度设置为错误
解决方案是将时间转换为
(double)
,或者简单地写100.0
秒是原始时间,而“IncreaseSpeedValue”是您需要增加的百分比吗?不清楚哪个变量意味着什么…这种方法有什么错?有什么地方做得不好?5
输入的预期输出是什么?您声明了,例如原始文件中的5秒=加速文件中的x秒
,但没有指定确切的关系或特定示例将产生什么结果。非常感谢!这太容易了。。。谢谢你抽出时间。我怎么会错过呢((