Dont display loading indicator if audio is not playing when voice is changed

This commit is contained in:
Jackson Harper 2022-09-26 20:46:28 +08:00
parent 5bb0b1246b
commit 247fcf0eb3
3 changed files with 7 additions and 3 deletions

View file

@ -32,7 +32,7 @@ struct TextToSpeechLanguageView: View {
Spacer()
if audioController.defaultLanguage == language.key {
if audioController.isLoading {
if audioController.isPlaying, audioController.isLoading {
ProgressView()
} else {
Image(systemName: "checkmark")

View file

@ -54,7 +54,7 @@ struct TextToSpeechVoiceSelectionView: View {
Spacer()
if voice.selected {
if audioController.isLoading {
if audioController.isPlaying, audioController.isLoading {
ProgressView()
} else {
Image(systemName: "checkmark")

View file

@ -525,6 +525,10 @@ public class AudioController: NSObject, ObservableObject, AVAudioPlayerDelegate
return (state == .loading || player?.currentItem == nil || player?.currentItem?.status == .unknown)
}
public var isPlaying: Bool {
state == .playing
}
public func isLoadingItem(itemID: String) -> Bool {
if state == .reachedEnd {
return false
@ -533,7 +537,7 @@ public class AudioController: NSObject, ObservableObject, AVAudioPlayerDelegate
}
public func isPlayingItem(itemID: String) -> Bool {
state == .playing && itemAudioProperties?.itemID == itemID
itemAudioProperties?.itemID == itemID && isPlaying
}
public func skipForward(seconds: Double) {