parent
e7427abf1e
commit
51fcb8835e
|
@ -16,7 +16,7 @@ final class ContentPlayManager: NSObject, ObservableObject {
|
|||
var creatorId = 0
|
||||
@Published var contentId: Int = 0
|
||||
|
||||
@Published private (set) var duration: TimeInterval = 0
|
||||
@Published private(set) var duration: TimeInterval = 0
|
||||
|
||||
@Published var title = ""
|
||||
@Published var nickname = ""
|
||||
|
@ -24,8 +24,8 @@ final class ContentPlayManager: NSObject, ObservableObject {
|
|||
|
||||
@Published var isFree: Bool? = nil
|
||||
@Published var isPreview: Bool? = nil
|
||||
@Published private (set) var isShowingMiniPlayer = false
|
||||
@Published private (set) var isPlaying = false
|
||||
@Published private(set) var isShowingMiniPlayer = false
|
||||
@Published private(set) var isPlaying = false
|
||||
|
||||
@Published var isLoading = false
|
||||
@Published var errorMessage = ""
|
||||
|
@ -170,6 +170,18 @@ extension ContentPlayManager {
|
|||
}
|
||||
}
|
||||
|
||||
func seekBackward10Seconds() {
|
||||
guard let player = player else { return }
|
||||
let newTime = max(player.currentTime - 10, 0)
|
||||
player.currentTime = newTime
|
||||
}
|
||||
|
||||
func seekForward10Seconds() {
|
||||
guard let player = player else { return }
|
||||
let newTime = min(player.currentTime + 10, player.duration)
|
||||
player.currentTime = newTime
|
||||
}
|
||||
|
||||
private func repeatAudio() {
|
||||
if let stopTimer = stopTimer {
|
||||
stopTimer()
|
||||
|
|
|
@ -53,28 +53,48 @@ struct ContentDetailPlayView: View {
|
|||
)
|
||||
.background(Color.black.opacity(0.6))
|
||||
} else if audioContent.releaseDate == nil && !isAlertPreview || (audioContent.isActivePreview && !audioContent.contentUrl.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) {
|
||||
Image(isPlaying() ? "btn_audio_content_pause" : isAlertPreview ? "btn_audio_content_preview_play" : "btn_audio_content_play")
|
||||
.onTapGesture {
|
||||
ContentPlayerPlayManager.shared.resetPlayer()
|
||||
|
||||
if isPlaying() {
|
||||
contentPlayManager.pauseAudio()
|
||||
} else {
|
||||
contentPlayManager.startTimer = startTimer
|
||||
contentPlayManager.stopTimer = stopTimer
|
||||
|
||||
contentPlayManager.playAudio(
|
||||
contentId: audioContent.contentId,
|
||||
title: audioContent.title,
|
||||
nickname: audioContent.creator.nickname,
|
||||
coverImage: audioContent.coverImageUrl,
|
||||
contentUrl: audioContent.contentUrl,
|
||||
isFree: audioContent.price <= 0,
|
||||
isPreview: !audioContent.existOrdered && audioContent.price > 0
|
||||
)
|
||||
isShowPreviewAlert = true
|
||||
}
|
||||
HStack(spacing: 24) {
|
||||
if !isAlertPreview {
|
||||
Image("ic_player_prev_10")
|
||||
.onTapGesture {
|
||||
if isPlaying() {
|
||||
contentPlayManager.seekBackward10Seconds()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image(isPlaying() ? "btn_audio_content_pause" : isAlertPreview ? "btn_audio_content_preview_play" : "btn_audio_content_play")
|
||||
.onTapGesture {
|
||||
ContentPlayerPlayManager.shared.resetPlayer()
|
||||
|
||||
if isPlaying() {
|
||||
contentPlayManager.pauseAudio()
|
||||
} else {
|
||||
contentPlayManager.startTimer = startTimer
|
||||
contentPlayManager.stopTimer = stopTimer
|
||||
|
||||
contentPlayManager.playAudio(
|
||||
contentId: audioContent.contentId,
|
||||
title: audioContent.title,
|
||||
nickname: audioContent.creator.nickname,
|
||||
coverImage: audioContent.coverImageUrl,
|
||||
contentUrl: audioContent.contentUrl,
|
||||
isFree: audioContent.price <= 0,
|
||||
isPreview: !audioContent.existOrdered && audioContent.price > 0
|
||||
)
|
||||
isShowPreviewAlert = true
|
||||
}
|
||||
}
|
||||
|
||||
if !isAlertPreview {
|
||||
Image("ic_player_next_10")
|
||||
.onTapGesture {
|
||||
if isPlaying() {
|
||||
contentPlayManager.seekForward10Seconds()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if audioContent.releaseDate == nil {
|
||||
Text("해당 콘텐츠는 크리에이터의 요청으로\n미리듣기를 제공하지 않습니다.")
|
||||
.font(.custom(Font.medium.rawValue, size: 16.7))
|
||||
|
|
Loading…
Reference in New Issue