diff --git a/SodaLive/Sources/Content/Player/AudioContentPlaylistManager.swift b/SodaLive/Sources/Content/Player/AudioContentPlaylistManager.swift index 0817071..f08dae3 100644 --- a/SodaLive/Sources/Content/Player/AudioContentPlaylistManager.swift +++ b/SodaLive/Sources/Content/Player/AudioContentPlaylistManager.swift @@ -34,6 +34,15 @@ class AudioContentPlaylistManager { return nil } + func findByContentId(contentId: Int) -> AudioContentPlaylistContent? { + if let index = playlist.firstIndex(where: { $0.id == contentId }), !playlist.isEmpty { + currentIndex = index + return playlist[index] + } + + return nil + } + func hasNextContent() -> Bool { return currentIndex + 1 < playlist.count } diff --git a/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift b/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift index 5684068..c32fb10 100644 --- a/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift +++ b/SodaLive/Sources/Content/Player/ContentPlayerPlayManager.swift @@ -174,8 +174,8 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject { } } - func playSelectedContent(content: AudioContentPlaylistContent) { - if content.id != id { + func playSelectedContent(contentId: Int) { + if let content = playlistManager?.findByContentId(contentId: contentId) { generateUrl(contentId: content.id) { [unowned self] url in self.urlGenerateSuccess(content: content, url: url) } onFailure: { diff --git a/SodaLive/Sources/Content/Player/ContentPlayerView.swift b/SodaLive/Sources/Content/Player/ContentPlayerView.swift index f9777c5..5b610d0 100644 --- a/SodaLive/Sources/Content/Player/ContentPlayerView.swift +++ b/SodaLive/Sources/Content/Player/ContentPlayerView.swift @@ -51,7 +51,7 @@ struct ContentPlayerView: View { .padding(.top, 21) } - Spacer() + Spacer(minLength: 13.3) if playerManager.isShowPlaylist { ScrollView(.vertical) { @@ -69,7 +69,7 @@ struct ContentPlayerView: View { ) .cornerRadius(6.7) .onTapGesture { - playerManager.playSelectedContent(content: item) + playerManager.playSelectedContent(contentId: item.id) } } }