콘텐츠 플레이어 - 재생목록
- 아이템을 터치했을 때 현재 index도 같이 변경되도록 수정해서 이전/이후 재생시 현재 아이템 기준으로 이전/이후 콘텐츠가 재생되도록 수정
This commit is contained in:
parent
7b3a3d2a80
commit
ee22a0a77e
|
@ -34,6 +34,15 @@ class AudioContentPlaylistManager {
|
||||||
return nil
|
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 {
|
func hasNextContent() -> Bool {
|
||||||
return currentIndex + 1 < playlist.count
|
return currentIndex + 1 < playlist.count
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,8 +174,8 @@ final class ContentPlayerPlayManager: NSObject, ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func playSelectedContent(content: AudioContentPlaylistContent) {
|
func playSelectedContent(contentId: Int) {
|
||||||
if content.id != id {
|
if let content = playlistManager?.findByContentId(contentId: contentId) {
|
||||||
generateUrl(contentId: content.id) { [unowned self] url in
|
generateUrl(contentId: content.id) { [unowned self] url in
|
||||||
self.urlGenerateSuccess(content: content, url: url)
|
self.urlGenerateSuccess(content: content, url: url)
|
||||||
} onFailure: {
|
} onFailure: {
|
||||||
|
|
|
@ -51,7 +51,7 @@ struct ContentPlayerView: View {
|
||||||
.padding(.top, 21)
|
.padding(.top, 21)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer()
|
Spacer(minLength: 13.3)
|
||||||
|
|
||||||
if playerManager.isShowPlaylist {
|
if playerManager.isShowPlaylist {
|
||||||
ScrollView(.vertical) {
|
ScrollView(.vertical) {
|
||||||
|
@ -69,7 +69,7 @@ struct ContentPlayerView: View {
|
||||||
)
|
)
|
||||||
.cornerRadius(6.7)
|
.cornerRadius(6.7)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
playerManager.playSelectedContent(content: item)
|
playerManager.playSelectedContent(contentId: item.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue