mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Set playback error if speech file does not download
This commit is contained in:
parent
5db983510b
commit
8bd9beebc6
4 changed files with 32 additions and 27 deletions
|
|
@ -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())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue