diff --git a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift index f4e3188ab..e540601bb 100644 --- a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/ExpandedPlayer.swift @@ -28,6 +28,9 @@ } var playPauseButtonItem: some View { + if audioController.playbackError { + return AnyView(Color.clear) + } if let itemID = audioController.itemAudioProperties?.itemID, audioController.isLoadingItem(itemID: itemID) { return AnyView(ProgressView()) } else { @@ -349,6 +352,9 @@ func playerContent(_: LinkedItemAudioProperties) -> some View { ZStack { + if audioController.playbackError { + Text("There was an error playing back your audio.").foregroundColor(Color.red).font(.footnote) + } audioCards .frame(maxHeight: .infinity) @@ -422,12 +428,10 @@ public var innerBody: some View { if let itemAudioProperties = self.audioController.itemAudioProperties { - return AnyView(playerContent(itemAudioProperties) - .tint(.appGrayTextContrast) - .alert("There was an error playing back your audio.", - isPresented: $audioController.playbackError) { - Button(LocalText.dismissButton, role: .none) {} - }) + return AnyView( + playerContent(itemAudioProperties) + .tint(.appGrayTextContrast) + ) } else { return AnyView(EmptyView()) } diff --git a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift index b719cd8f8..861da9bdb 100644 --- a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift @@ -34,6 +34,9 @@ } var playPauseButtonItem: some View { + if audioController.playbackError { + return AnyView(Color.clear) + } if let itemID = audioController.itemAudioProperties?.itemID, audioController.isLoadingItem(itemID: itemID) { return AnyView(ProgressView()) } else { @@ -121,21 +124,25 @@ func playerContent(_ itemAudioProperties: LinkedItemAudioProperties) -> some View { VStack(spacing: 0) { HStack(alignment: .center, spacing: 15) { - artwork(itemAudioProperties, forDimensions: 50) + if audioController.playbackError { + Text("There was an error playing back your audio.").foregroundColor(Color.red).font(.footnote) + Spacer(minLength: 0) + } else { + artwork(itemAudioProperties, forDimensions: 50) - Text(itemAudioProperties.title) - .font(Font.system(size: 17, weight: .medium)) - .fixedSize(horizontal: false, vertical: true) - .lineLimit(2) - .foregroundColor(.appGrayTextContrast) - .frame(maxHeight: 40, alignment: .leading) + Text(itemAudioProperties.title) + .font(Font.system(size: 17, weight: .medium)) + .fixedSize(horizontal: false, vertical: true) + .lineLimit(2) + .foregroundColor(.appGrayTextContrast) + .frame(maxHeight: 40, alignment: .leading) - Spacer(minLength: 0) - - playPauseButtonItem - .frame(width: 40, height: 40) - .foregroundColor(.themeAudioPlayerGray) + Spacer(minLength: 0) + playPauseButtonItem + .frame(width: 40, height: 40) + .foregroundColor(.themeAudioPlayerGray) + } stopButton .frame(width: 40, height: 40) .foregroundColor(.themeAudioPlayerGray) @@ -169,14 +176,9 @@ Spacer(minLength: 0) playerContent(itemAudioProperties) .frame(maxHeight: expanded ? 0 : 110) - // .tint(.appGrayTextContrast) - // .background(Color.systemBackground) } } } - }.alert("There was an error playing back your audio.", - isPresented: $audioController.playbackError) { - Button(LocalText.dismissButton, role: .none) {} } } } diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift index 9a1499d38..aba8bf1ca 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift @@ -126,7 +126,7 @@ struct WebReaderContainerView: View { #if os(iOS) var audioNavbarItem: some View { - if audioController.isLoadingItem(itemID: item.unwrappedID) { + if !audioController.playbackError, audioController.isLoadingItem(itemID: item.unwrappedID) { return AnyView(ProgressView() .padding(.horizontal)) } else { @@ -157,7 +157,7 @@ struct WebReaderContainerView: View { } var textToSpeechButtonImage: some View { - if audioController.state == .stopped || audioController.itemAudioProperties?.itemID != self.item.id { + if audioController.playbackError || audioController.state == .stopped || audioController.itemAudioProperties?.itemID != self.item.id { return AnyView(Image.headphones) } let name = audioController.isPlayingItem(itemID: item.unwrappedID) ? "pause.circle" : "play.circle" diff --git a/apple/OmnivoreKit/Sources/Services/AudioSession/AudioController.swift b/apple/OmnivoreKit/Sources/Services/AudioSession/AudioController.swift index eafd76718..fad2c45be 100644 --- a/apple/OmnivoreKit/Sources/Services/AudioSession/AudioController.swift +++ b/apple/OmnivoreKit/Sources/Services/AudioSession/AudioController.swift @@ -576,8 +576,7 @@ let startOffset = index < document.utterances.count ? offset : 0.0 self.startStreamingAudio(itemID: itemID, document: document, atIndex: startIndex, andOffset: startOffset) } else { - print("unable to load speech document") - // TODO: Post error to SnackBar + self.playbackError = true } } }