플레이어 재생 완료
- 다음 재생할 콘텐츠가 없을 때 서비스를 종료해 플레이어에서 재생 및 이전/다음 콘텐츠 재생이 안되는 버그 수정
This commit is contained in:
@@ -236,7 +236,11 @@ class AudioContentPlayerFragment(
|
||||
override fun onPlaybackStateChanged(playbackState: Int) {
|
||||
mediaController?.let {
|
||||
when (playbackState) {
|
||||
Player.STATE_ENDED -> it.seekTo(0)
|
||||
Player.STATE_ENDED -> {
|
||||
it.seekTo(0)
|
||||
it.pause()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
@@ -104,8 +104,6 @@ class AudioContentPlayerService : MediaSessionService() {
|
||||
} else if (playbackState == Player.STATE_ENDED) {
|
||||
if (playlistManager!!.hasNextContent()) {
|
||||
playNextContent()
|
||||
} else {
|
||||
onStopService()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,8 +265,8 @@ class AudioContentPlayerService : MediaSessionService() {
|
||||
content.id,
|
||||
onSuccess = { urlGenerateSuccess(content, it) },
|
||||
onFailure = {
|
||||
if (playlistManager!!.hasNextContent()) {
|
||||
playNextContent()
|
||||
if (playlistManager!!.hasPreviousContent()) {
|
||||
playPreviousContent()
|
||||
} else {
|
||||
onStopService()
|
||||
}
|
||||
@@ -291,7 +289,7 @@ class AudioContentPlayerService : MediaSessionService() {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
if (it.success && it.data != null) {
|
||||
if (it.success && it.data != null && it.data.contentUrl.isNotBlank()) {
|
||||
onSuccess(it.data.contentUrl)
|
||||
} else {
|
||||
onFailure()
|
||||
|
@@ -24,4 +24,8 @@ class AudioContentPlaylistManager(private val playlist: List<AudioContentPlaylis
|
||||
fun hasNextContent(): Boolean {
|
||||
return currentIndex + 1 < playlist.size
|
||||
}
|
||||
|
||||
fun hasPreviousContent(): Boolean {
|
||||
return currentIndex - 1 > 0
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user