Skip to content

Commit c69153a

Browse files
committed
[Bug修复](dev_4.0.6): 修复资源切换弹幕进度问题
1 parent dcc22a1 commit c69153a

File tree

1 file changed

+9
-5
lines changed
  • player_component/src/main/java/com/xyoye/player/controller/danmu

1 file changed

+9
-5
lines changed

player_component/src/main/java/com/xyoye/player/controller/danmu/DanmuView.kt

+9-5
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,13 @@ class DanmuView(
7676
post {
7777
isDanmuLoaded = true
7878
if (mControlWrapper.isPlaying()) {
79-
val position =
79+
val position = if (mSeekPosition == INVALID_VALUE) {
8080
mControlWrapper.getCurrentPosition() + PlayerInitializer.Danmu.offsetPosition
81-
start(position)
81+
} else {
82+
mSeekPosition
83+
}
84+
seekTo(position)
85+
mSeekPosition = INVALID_VALUE
8286
}
8387
}
8488
}
@@ -108,7 +112,7 @@ class DanmuView(
108112
}
109113
}
110114
PlayState.STATE_BUFFERING_PAUSED -> {
111-
if (isPrepared){
115+
if (isPrepared) {
112116
pause()
113117
}
114118
}
@@ -157,7 +161,7 @@ class DanmuView(
157161
}
158162

159163
fun seekTo(timeMs: Long, isPlaying: Boolean) {
160-
if (isPlaying) {
164+
if (isPlaying && isDanmuLoaded) {
161165
seekTo(timeMs + PlayerInitializer.Danmu.offsetPosition)
162166
} else {
163167
mSeekPosition = timeMs + PlayerInitializer.Danmu.offsetPosition
@@ -344,7 +348,7 @@ class DanmuView(
344348
addDanmaku(danmaku)
345349
}
346350

347-
fun setSpeed(speed: Float){
351+
fun setSpeed(speed: Float) {
348352
mDanmakuContext.setSpeed(speed)
349353
}
350354

0 commit comments

Comments
 (0)