Skip to content

Assignment6#2

Open
Ssunghyn wants to merge 2 commits intomainfrom
Assignment6
Open

Assignment6#2
Ssunghyn wants to merge 2 commits intomainfrom
Assignment6

Conversation

@Ssunghyn
Copy link
Owner

실습과제 6번입니다.

Ssunghyn added 2 commits June 20, 2021 20:47
음악플레이어 구현하기
@Ssunghyn Ssunghyn requested review from ksu9080 and yunjaena June 20, 2021 11:57
Copy link
Collaborator

@yunjaena yunjaena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foreground 서비스에서 뮤직 플레이어를 Control 하는 로직을 추가 해보는 것도 해보시면 좋을 것 같아요 :) 전반적으로 코드가 깔끔해서 좋네요 !!

lateinit var runnable: Runnable
lateinit var mediaPlayer : MediaPlayer
private var handler = Handler()
val CHANNELID = "MusicPlayer"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공통으로 사용하는 상수는 companion object 로 선언하는게 좋습니다.

companion object{
  const val CHANNEL_ID = "MusicPlayer"
}

import android.os.Build
import androidx.core.app.NotificationCompat

object MusicNotification {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MusicNotification을 사용하는 곳이 안보이네요!! action을 처리하는 부분도 필요할 것 같습니다.

}

previous.setOnClickListener {
seekBar.progress=mediaPlayer.currentPosition-5000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-5000 이면 0 보다 작아질수도 있으니 0보다 작아지면 0초로 돌리거나 이전 곡으로 이동하는 로직을 추가하면 어떨까요?

}

next.setOnClickListener {
seekBar.progress=mediaPlayer.currentPosition+5000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이부분도 마찬가지로 음악 길이를 넘어갈 수 있으니 검사하는 로직이 필요할 것 같습니다.


runnable = Runnable {
seekBar.progress = mediaPlayer.currentPosition
handler.postDelayed(runnable,1000)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runnable 안에서 handler를 통해 실행하는 이유는 무엇인가요? 78번째 라인에서 핸들링 될 것 같습니다.

exitProcess(0)
}

fun createNotificationChannel() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MusicNotification class에서 같이 선언해주시면 좋을 것 같습니다 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants