-
-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Maybe I'm weird, maybe there are a lot of people like me, but....
I need functionality to calculate the duration of a video or audio taking into account the playback speed. I even wrote a rough version of such code and would like to suggest adding it to the application.
This is my implementation of this idea in clear kotlin:
import java.util.Scanner
class VideoDuration(
var hours: Int = 0,
var minutes: Int = 0,
var seconds: Int = 0,
var playbackSpeed: Double = 1.0
) {
fun totalDurationInSeconds(): Int {
return hours * 3600 + minutes * 60 + seconds
}
fun adjustedDuration(): Double {
val totalSeconds = totalDurationInSeconds()
return totalSeconds / playbackSpeed
}
fun displayAdjustedDuration() {
val adjustedSeconds = adjustedDuration()
val adjustedHours = (adjustedSeconds / 3600).toInt()
val adjustedMinutes = ((adjustedSeconds % 3600) / 60).toInt()
val adjustedSecondsFinal = (adjustedSeconds % 60).toInt()
println("Adjusted duration: $adjustedHours hours, $adjustedMinutes minutes, $adjustedSecondsFinal seconds")
}
}
fun main() {
val scanner = Scanner(System.`in`)
println("Enter the duration of the video:")
print("Hours: ")
val hours = scanner.nextInt()
print("Minutes: ")
val minutes = scanner.nextInt()
print("Seconds: ")
val seconds = scanner.nextInt()
print("Enter the playback speed (e.g., 1.5 for 1.5x): ")
val playbackSpeedInput = scanner.next() // Read as a string
val playbackSpeed = playbackSpeedInput.replace(',', '.').replace("x", "").toDouble() // Clean input and convert to double
val video = VideoDuration(hours, minutes, seconds, playbackSpeed)
video.displayAdjustedDuration()
}
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request