-
Notifications
You must be signed in to change notification settings - Fork 1
연습 녹음 화면 구현 #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HamBeomJoon
wants to merge
34
commits into
develop
Choose a base branch
from
feat/#101-practice-record
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
연습 녹음 화면 구현 #124
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
c35256c
feat: 연습 녹음 기능 구현 및 홈 화면 연동
HamBeomJoon ce7bbbd
feat: 연습 녹음 분석 결과 및 상태(Loading/Error/Success) 화면 구현
HamBeomJoon 0c901bb
feat: 연습 녹음 기능의 예외 처리 강화 및 상태 관리 리팩터링
HamBeomJoon eb8b122
refactor: 연습 녹음 기능 구조 개선 및 코드 리팩터링
HamBeomJoon 24c2b47
refactor: 연습 녹음 분석 결과 화면 패키지 구조 개선 및 컴포넌트 정리
HamBeomJoon 11f3854
feat: 연습 녹음 분석 기능 구현 및 관련 도메인/데이터 레이어 추가
HamBeomJoon 9f90412
feat: 연습 녹음 화면 권한 처리 로직 개선 및 오류 처리 강화
HamBeomJoon cf07025
feat: 연습(Practice) 관련 UseCase KDoc 주석 추가
HamBeomJoon 52331c6
refactor: 녹음 권한 요청 로직 간소화 및 오디오 컨트롤러 상태 초기화 로직 개선
HamBeomJoon 97b3d74
feat: 공통 권한 요청 유틸리티 구현 및 오디오 녹음 로직 개선
HamBeomJoon 3fc3663
feat: 연습 녹음 분석 기능 구현 및 오디오 로직 리팩터링
HamBeomJoon d8e4d9c
refactor: 오디오 녹음 로직 core 모듈 분리 및 권한 요청 로직 개선
HamBeomJoon aa8c634
feat: 음성 녹음 및 외부 오디오 파일 선택 기능 고도화
HamBeomJoon 582aed0
Merge remote-tracking branch 'origin/develop' into feat/#101-practice…
HamBeomJoon 7b06176
refactor: 홈 화면 코드 구조 개선 및 녹음 로직 간소화
HamBeomJoon ac2b6aa
refactor: 연습 녹음(Practice Recording) 상태 관리 및 결과 화면 로직 개선
HamBeomJoon 92fc811
refactor: `RecordingAudioController` 내 `Immutable` 어노테이션 교체 및 의존성 정리
HamBeomJoon 1ce3b6e
Merge remote-tracking branch 'origin/develop' into feat/#101-practice…
HamBeomJoon f2a0fa2
refactor: 오디오 관련 도메인 모델 및 상태 인터페이스 분리
HamBeomJoon a83f59a
refactor: 연습 결과 페이지의 칩(Chip) 컴포넌트 사용 로직 간소화 및 코드 포맷팅 개선
HamBeomJoon 853d1d2
feat: 연습 녹음 분석 기능 구현 및 관련 API 연동
HamBeomJoon cb1713d
feat: 연습 녹음 분석 결과에 종합 평가(Overall Evaluation) 추가 및 도메인 모델 통합
HamBeomJoon 18ac526
Merge remote-tracking branch 'origin/develop' into feat/#101-practice…
HamBeomJoon 167fc1d
refactor: 연습(Practice) 기능을 별도 모듈로 분리 및 분석 로직 개선
HamBeomJoon 1ca917a
refactor: `PracticeRecordingUiState` 구조 개선 및 오디오 재생 로직 리팩터링
HamBeomJoon 594c28a
refactor: `MediaRecordingAudioController` 리팩터링 및 오디오 세션 로직 분리
HamBeomJoon ac9949d
refactor: PracticeRecordingUiIntent 정리 및 스크립트 로드 로직 개선
HamBeomJoon ee8b7aa
build: app 모듈 내 불필요한 feature API 의존성 제거
moondev03 6e176e0
feat: 연습 녹음 분석 기능 분리 및 아키텍처 개선
HamBeomJoon bd8b829
feat: Audio 관련 세션 인터페이스 도입 및 의존성 주입 구조 개선
HamBeomJoon 67f3082
Merge remote-tracking branch 'origin/feat/#101-practice-record' into …
HamBeomJoon 76105e2
build: practice feature implementation 모듈에 serialization 플러그인 추가
moondev03 318eb99
refactor: 연습 기록 및 분석 기능 구조 개선 및 패키지 정리
moondev03 117d3b7
refactor: 홈 화면 연습 녹음 네비게이션 경로 수정
moondev03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| plugins { | ||
| alias(libs.plugins.prezel.android.library) | ||
| alias(libs.plugins.prezel.hilt) | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.team.prezel.core.audio" | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(platform(libs.androidx.compose.bom)) | ||
| implementation(libs.androidx.compose.runtime) | ||
| implementation(libs.kotlinx.coroutines.core) | ||
| } | ||
13 changes: 13 additions & 0 deletions
13
Prezel/core/audio/src/main/java/com/team/prezel/core/audio/AudioPlayerSession.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.team.prezel.core.audio | ||
|
|
||
| internal interface AudioPlayerSession { | ||
| fun start( | ||
| source: AudioSource, | ||
| startPositionSeconds: Int, | ||
| onCompleted: () -> Unit, | ||
| ): Result<Int> | ||
|
|
||
| fun currentPositionSeconds(): Int | ||
|
|
||
| fun release() | ||
| } |
9 changes: 9 additions & 0 deletions
9
Prezel/core/audio/src/main/java/com/team/prezel/core/audio/AudioRecorderSession.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.team.prezel.core.audio | ||
|
|
||
| internal interface AudioRecorderSession { | ||
| fun start(): Result<Unit> | ||
|
|
||
| fun stop(elapsedSeconds: Int): Result<RecordedAudio> | ||
|
|
||
| fun reset() | ||
| } |
9 changes: 9 additions & 0 deletions
9
Prezel/core/audio/src/main/java/com/team/prezel/core/audio/AudioSessionEffect.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.team.prezel.core.audio | ||
|
|
||
| sealed interface AudioSessionEffect { | ||
| data object RecordingStartFailed : AudioSessionEffect | ||
|
|
||
| data object RecordingStopFailed : AudioSessionEffect | ||
|
|
||
| data object PlaybackStartFailed : AudioSessionEffect | ||
| } |
33 changes: 33 additions & 0 deletions
33
Prezel/core/audio/src/main/java/com/team/prezel/core/audio/AudioSessionState.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.team.prezel.core.audio | ||
|
|
||
| import androidx.compose.runtime.Immutable | ||
|
|
||
| @Immutable | ||
| sealed interface AudioSessionState { | ||
| data object Idle : AudioSessionState | ||
|
|
||
| data class Recording( | ||
| val elapsedSeconds: Int, | ||
| ) : AudioSessionState | ||
|
|
||
| data class ReadyToPlay( | ||
| val source: AudioSource, | ||
| val positionSeconds: Int = 0, | ||
| val durationSeconds: Int, | ||
| ) : AudioSessionState | ||
|
|
||
| data class Playing( | ||
| val source: AudioSource, | ||
| val positionSeconds: Int, | ||
| val durationSeconds: Int, | ||
| ) : AudioSessionState | ||
| } | ||
|
|
||
| @Immutable | ||
| sealed interface AudioSource { | ||
| val filePath: String | ||
|
|
||
| data class RecordedFile( | ||
| override val filePath: String, | ||
| ) : AudioSource | ||
| } |
56 changes: 56 additions & 0 deletions
56
Prezel/core/audio/src/main/java/com/team/prezel/core/audio/MediaPlayerSession.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package com.team.prezel.core.audio | ||
|
|
||
| import android.media.MediaPlayer | ||
| import javax.inject.Inject | ||
|
|
||
| internal class MediaPlayerSession @Inject constructor() : AudioPlayerSession { | ||
| private var player: MediaPlayer? = null | ||
|
|
||
| override fun start( | ||
| source: AudioSource, | ||
| startPositionSeconds: Int, | ||
| onCompleted: () -> Unit, | ||
| ): Result<Int> = | ||
| runCatching { | ||
| release() | ||
|
|
||
| var pendingPlayer: MediaPlayer? = null | ||
| val newPlayer = runCatching { | ||
| MediaPlayer().also { pendingPlayer = it }.apply { | ||
| setDataSource(source.filePath) | ||
| prepare() | ||
| seekToStartPosition(startPositionSeconds) | ||
| setOnCompletionListener { onCompleted() } | ||
| start() | ||
| } | ||
| }.getOrElse { throwable -> | ||
| pendingPlayer?.release() | ||
| throw throwable | ||
| } | ||
|
|
||
| player = newPlayer | ||
| newPlayer.duration | ||
| }.onFailure { | ||
| release() | ||
| } | ||
|
|
||
| override fun currentPositionSeconds(): Int = player?.currentPosition?.toSeconds() ?: 0 | ||
|
|
||
| override fun release() { | ||
| player?.runCatching { stop() } | ||
| player?.release() | ||
| player = null | ||
| } | ||
|
|
||
| private fun MediaPlayer.seekToStartPosition(startPositionSeconds: Int) { | ||
| if (startPositionSeconds > 0) { | ||
| seekTo(startPositionSeconds * MILLIS_PER_SECOND) | ||
| } | ||
| } | ||
|
|
||
| private companion object { | ||
| const val MILLIS_PER_SECOND = 1_000 | ||
| } | ||
| } | ||
|
|
||
| internal fun Int.toSeconds(): Int = this / 1_000 |
81 changes: 81 additions & 0 deletions
81
Prezel/core/audio/src/main/java/com/team/prezel/core/audio/MediaRecorderSession.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package com.team.prezel.core.audio | ||
|
|
||
| import android.content.Context | ||
| import android.media.MediaRecorder | ||
| import android.os.Build | ||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||
| import java.io.File | ||
| import javax.inject.Inject | ||
| import kotlin.math.max | ||
|
|
||
| internal class MediaRecorderSession @Inject constructor( | ||
| @param:ApplicationContext private val context: Context, | ||
| ) : AudioRecorderSession { | ||
| private var recorder: MediaRecorder? = null | ||
| private var currentAudioFile: File? = null | ||
|
|
||
| override fun start(): Result<Unit> = | ||
| runCatching { | ||
| reset() | ||
|
|
||
| val file = File.createTempFile("recording_", ".m4a", context.cacheDir) | ||
| var pendingRecorder: MediaRecorder? = null | ||
| val newRecorder = runCatching { | ||
| createMediaRecorder(context = context).also { pendingRecorder = it }.apply { | ||
| setAudioSource(MediaRecorder.AudioSource.MIC) | ||
| setOutputFormat(MediaRecorder.OutputFormat.MPEG_4) | ||
| setAudioEncoder(MediaRecorder.AudioEncoder.AAC) | ||
| setOutputFile(file.absolutePath) | ||
| prepare() | ||
| start() | ||
| } | ||
| }.getOrElse { throwable -> | ||
| pendingRecorder?.release() | ||
| file.delete() | ||
| throw throwable | ||
| } | ||
|
|
||
| recorder = newRecorder | ||
| currentAudioFile = file | ||
| }.onFailure { | ||
| reset() | ||
| } | ||
|
|
||
| override fun stop(elapsedSeconds: Int): Result<RecordedAudio> = | ||
| runCatching { | ||
| val file = currentAudioFile!! | ||
| recorder!!.stop() | ||
| RecordedAudio( | ||
| source = AudioSource.RecordedFile(filePath = file.absolutePath), | ||
| durationSeconds = max(elapsedSeconds, 0), | ||
| ) | ||
| }.onSuccess { | ||
| releaseRecorder() | ||
| }.onFailure { | ||
| reset() | ||
| } | ||
|
|
||
| override fun reset() { | ||
| releaseRecorder() | ||
| currentAudioFile?.delete() | ||
| currentAudioFile = null | ||
| } | ||
|
|
||
| private fun releaseRecorder() { | ||
| recorder?.release() | ||
| recorder = null | ||
| } | ||
| } | ||
|
|
||
| internal data class RecordedAudio( | ||
| val source: AudioSource.RecordedFile, | ||
| val durationSeconds: Int, | ||
| ) | ||
|
|
||
| @Suppress("DEPRECATION") | ||
| private fun createMediaRecorder(context: Context): MediaRecorder = | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
| MediaRecorder(context) | ||
| } else { | ||
| MediaRecorder() | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.