diff --git a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift index e8c5aa8a5..5ffd9020a 100644 --- a/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/AudioPlayer/MiniPlayer.swift @@ -153,27 +153,29 @@ var audioCards: some View { ZStack { let textItems = self.audioController.textItems ?? [] - TabView(selection: $tabIndex) { - ForEach(0 ..< textItems.count, id: \.self) { id in - SpeechCard(id: id) - .tag(id) - } - } - .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never)) - .onChange(of: tabIndex, perform: { index in - if index != audioController.currentAudioIndex, index < (audioController.textItems?.count ?? 0) { - audioController.seek(toUtterance: index) - } - }) - .onChange(of: audioController.currentAudioIndex, perform: { index in - if index >= textItems.count { - return + if textItems.count > 0 { + TabView(selection: $tabIndex) { + ForEach(0 ..< textItems.count, id: \.self) { id in + SpeechCard(id: id) + .tag(id) + } } + .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never)) + .onChange(of: tabIndex, perform: { index in + if index != audioController.currentAudioIndex, index < (audioController.textItems?.count ?? 0) { + audioController.seek(toUtterance: index) + } + }) + .onChange(of: audioController.currentAudioIndex, perform: { index in + if index >= textItems.count { + return + } - if self.audioController.state != .reachedEnd { - tabIndex = index - } - }) + if self.audioController.state != .reachedEnd { + tabIndex = index + } + }) + } if audioController.state == .reachedEnd { // If we have reached the end display a replay button with an overlay behind diff --git a/apple/OmnivoreKit/Sources/Services/AudioSession/AudioController.swift b/apple/OmnivoreKit/Sources/Services/AudioSession/AudioController.swift index e1598bc75..40a40b773 100644 --- a/apple/OmnivoreKit/Sources/Services/AudioSession/AudioController.swift +++ b/apple/OmnivoreKit/Sources/Services/AudioSession/AudioController.swift @@ -207,6 +207,8 @@ @Published public var durationString: String? @Published public var voiceList: [(name: String, key: String, category: VoiceCategory, selected: Bool)]? + @Published public var textItems: [String]? + let dataService: DataService var timer: Timer? @@ -480,8 +482,6 @@ let body: String } - public var textItems: [String]? - func setTextItems() { if let document = self.document { textItems = document.utterances.map { utterance in