[v630] fix: MediaPlayer第一次必须在主线程初始化,否则第二次play会出现IllegalStateException异常;
This commit is contained in:
@@ -6,6 +6,7 @@ import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.os.Message
|
||||
import android.text.TextUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
|
||||
object Audition: MediaPlayer.OnPreparedListener,
|
||||
MediaPlayer.OnCompletionListener, MediaPlayer.OnSeekCompleteListener,
|
||||
@@ -58,6 +59,7 @@ object Audition: MediaPlayer.OnPreparedListener,
|
||||
|
||||
fun play(path: String) {
|
||||
if (TextUtils.equals(oldPath, path)) {
|
||||
CallerLogger.i(TAG, "play() , return")
|
||||
return
|
||||
}
|
||||
oldPath = path
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.mogo.och.common.module.manager.auditionmanager
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.common.module.manager.audiofocusmanager.AudioFocusManager
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@@ -84,8 +86,10 @@ object AuditionManager: AuditionCacheManager.DataChangeListener, Audition.OnAudi
|
||||
}
|
||||
|
||||
fun playFirst(){
|
||||
if(!isPlaying()){
|
||||
toggle(musicList.first())
|
||||
ThreadUtils.runOnUiThread {
|
||||
if(!isPlaying()){
|
||||
toggle(musicList.first())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user