Skip to content

Commit

Permalink
Add remaining time to VoiceOver label
Browse files Browse the repository at this point in the history
  • Loading branch information
GianniCarlo committed Dec 26, 2024
1 parent 275a4b9 commit c6866be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
askForAppToLaunch = "Yes"
launchAutomaticallySubstyle = "2">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
24 changes: 20 additions & 4 deletions BookPlayer/Services/VoiceOverService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ class VoiceOverService {
// MARK: - BookCellView

public static func getAccessibilityLabel(for item: SimpleLibraryItem) -> String {
let remainingTime = item.duration - item.currentTime
var remainingTimeLabel = "book_time_remaining_title".localized
if remainingTime > 0 && remainingTime.isFinite {
let parsedDuration = VoiceOverService.secondsToMinutes(remainingTime)
remainingTimeLabel += !parsedDuration.isEmpty ? " \(parsedDuration)" : " 0"
}
switch item.type {
case .book:
return String.localizedStringWithFormat(
Expand All @@ -13,7 +19,7 @@ class VoiceOverService {
item.details,
item.percentCompleted,
item.durationFormatted
)
) + ", \(remainingTimeLabel)"
case .folder:
return String.localizedStringWithFormat(
"voiceover_playlist_progress".localized,
Expand All @@ -26,7 +32,7 @@ class VoiceOverService {
item.title,
item.percentCompleted,
item.durationFormatted
)
) + ", \(remainingTimeLabel)"
}
}

Expand All @@ -42,11 +48,21 @@ class VoiceOverService {
// MARK: - ArtworkControl

public static func rewindText() -> String {
return String(describing: String.localizedStringWithFormat("voiceover_rewind_time".localized, self.secondsToMinutes(PlayerManager.rewindInterval.rounded())))
return String(
describing: String.localizedStringWithFormat(
"voiceover_rewind_time".localized,
self.secondsToMinutes(PlayerManager.rewindInterval.rounded())
)
)
}

public static func fastForwardText() -> String {
return String(describing: String.localizedStringWithFormat("voiceover_forward_time".localized, self.secondsToMinutes(PlayerManager.forwardInterval.rounded())))
return String(
describing: String.localizedStringWithFormat(
"voiceover_forward_time".localized,
self.secondsToMinutes(PlayerManager.forwardInterval.rounded())
)
)
}

public static func secondsToMinutes(_ interval: TimeInterval) -> String {
Expand Down

0 comments on commit c6866be

Please sign in to comment.