File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
app/src/main/java/com/runnect/runnect/presentation/run Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ import com.runnect.runnect.data.dto.TimerData
3535import com.runnect.runnect.databinding.ActivityRunBinding
3636import com.runnect.runnect.presentation.endrun.EndRunActivity
3737import com.runnect.runnect.presentation.run.TimerService.Companion.EXTRA_TIMER_VALUE
38+ import com.runnect.runnect.presentation.run.TimerService.Companion.TIMER_UPDATE_ACTION
3839import com.runnect.runnect.util.extension.round
3940
4041class RunActivity :
@@ -124,7 +125,7 @@ class RunActivity :
124125 override fun onStart () {
125126 super .onStart()
126127 // Timer 결과값을 받기 위해 브로드캐스트 리시버 등록
127- registerReceiver(timerReceiver, IntentFilter (TimerService . TIMER_UPDATE_ACTION ))
128+ registerReceiver(timerReceiver, IntentFilter (TIMER_UPDATE_ACTION ))
128129 }
129130
130131 override fun onStop () {
Original file line number Diff line number Diff line change @@ -39,6 +39,16 @@ class TimerService : Service() {
3939 return START_STICKY
4040 }
4141
42+ fun notifyStartRun () {
43+ if (player == null ) {
44+ player = MediaPlayer .create(this @TimerService, R .raw.start_run)
45+ player?.setOnCompletionListener { mediaPlayer ->
46+ mediaPlayer.release() // 재생이 끝나면 MediaPlayer 객체를 해제합니다.
47+ }
48+ }
49+ player?.start()
50+ }
51+
4252 fun startTimer () {
4353 timer = Timer ()
4454 timer?.scheduleAtFixedRate(object : TimerTask () {
@@ -86,6 +96,7 @@ class TimerService : Service() {
8696 .setColor(ContextCompat .getColor(this @TimerService, R .color.M1 ))
8797 .setContentTitle(" 러닝" )
8898 .setContentText(" 00:00:00" )
99+ .setOnlyAlertOnce(true )
89100 .setOngoing(true ) // true 일 경우 알림 리스트에서 클릭하거나 좌우로 드래그해도 사라지지 않음
90101
91102 val notificationIntent = Intent (this @TimerService, RunActivity ::class .java)
@@ -119,16 +130,6 @@ class TimerService : Service() {
119130 startForeground(NOTI_ID , notification)
120131 }
121132
122- fun notifyStartRun () {
123- if (player == null ) {
124- player = MediaPlayer .create(this @TimerService, R .raw.start_run)
125- player?.setOnCompletionListener { mediaPlayer ->
126- mediaPlayer.release() // 재생이 끝나면 MediaPlayer 객체를 해제합니다.
127- }
128- }
129- player?.start()
130- }
131-
132133 companion object {
133134 const val TIMER_UPDATE_ACTION = " TIMER_UPDATE_ACTION"
134135 const val EXTRA_TIMER_VALUE = " EXTRA_TIMER_VALUE"
You can’t perform that action at this time.
0 commit comments