오디션 - 오디오 재생기능 추가
This commit is contained in:
@@ -13,6 +13,8 @@ struct AuditionApplicantItemView: View {
|
||||
let item: GetAuditionRoleApplicantItem
|
||||
let onClickVote: (Int) -> Void
|
||||
|
||||
@StateObject var soundManager = AuditionSoundManager.shared
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 5.3) {
|
||||
HStack(spacing: 13.3) {
|
||||
@@ -26,8 +28,12 @@ struct AuditionApplicantItemView: View {
|
||||
.frame(width: 40, height: 40)
|
||||
.clipShape(Circle())
|
||||
|
||||
Image("ic_audition_play")
|
||||
Image(soundManager.applicantId == item.applicantId && soundManager.isPlaying ? "ic_audition_pause" : "ic_audition_play")
|
||||
.onTapGesture {
|
||||
soundManager.playOrPause(
|
||||
applicantId: item.applicantId,
|
||||
url: item.voiceUrl
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +44,17 @@ struct AuditionApplicantItemView: View {
|
||||
.foregroundColor(Color.white)
|
||||
|
||||
Spacer()
|
||||
|
||||
if soundManager.applicantId == item.applicantId {
|
||||
Text("\(secondsToMinutesSeconds(Int(soundManager.currentTime)))/\(secondsToMinutesSeconds(Int(soundManager.duration)))")
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.foregroundColor(Color.gray77)
|
||||
}
|
||||
}
|
||||
|
||||
if soundManager.applicantId == item.applicantId {
|
||||
ProgressView(value: soundManager.currentTime, total: soundManager.duration)
|
||||
.progressViewStyle(LinearProgressViewStyle(tint: Color.button))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +77,13 @@ struct AuditionApplicantItemView: View {
|
||||
}
|
||||
.padding(.horizontal, 13.3)
|
||||
}
|
||||
|
||||
private func secondsToMinutesSeconds(_ seconds: Int) -> String {
|
||||
let minute = String(format: "%02d", seconds / 60)
|
||||
let second = String(format: "%02d", seconds % 60)
|
||||
|
||||
return "\(minute):\(second)"
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
|
Reference in New Issue
Block a user