[6.3.0]
[music] [seek实现]
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,
|
||||
@@ -117,14 +118,8 @@ object Audition: MediaPlayer.OnPreparedListener,
|
||||
return false
|
||||
}
|
||||
|
||||
fun playOrStop(path: String): Boolean {
|
||||
return if (!TextUtils.equals(oldPath, path)) {
|
||||
play(path)
|
||||
true
|
||||
} else {
|
||||
stop()
|
||||
false
|
||||
}
|
||||
fun seekTo(progress: Int){
|
||||
mediaPlayer?.seekTo(progress)
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
@@ -141,10 +136,11 @@ object Audition: MediaPlayer.OnPreparedListener,
|
||||
}
|
||||
|
||||
override fun onCompletion(mp: MediaPlayer) {
|
||||
if (listener != null) {
|
||||
listener!!.onAuditionCompletion(oldPath)
|
||||
}
|
||||
val tempPath = oldPath
|
||||
oldPath = null
|
||||
if (listener != null) {
|
||||
listener!!.onAuditionCompletion(tempPath)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSeekComplete(mp: MediaPlayer) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.och.common.module.manager.auditionmanager
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.och.common.module.manager.distancemamager.IDistanceListener
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
@@ -10,6 +11,8 @@ object AuditionManager: AuditionCacheManager.DataChangeListener, Audition.OnAudi
|
||||
|
||||
private val dataChangeListeners: ConcurrentHashMap<String, MusicDataChangeListener> = ConcurrentHashMap()
|
||||
|
||||
private const val TAG = "AuditionManager"
|
||||
|
||||
init {
|
||||
AuditionCacheManager.addDataChangeListener(this)
|
||||
Audition.registerOnAuditionListener(this)
|
||||
@@ -89,6 +92,7 @@ object AuditionManager: AuditionCacheManager.DataChangeListener, Audition.OnAudi
|
||||
*/
|
||||
override fun onAuditionCompletion(path:String?) {
|
||||
val oldData = resetData()
|
||||
CallerLogger.d(TAG,"播放完成:${oldData?.songName}--${path}")
|
||||
if(oldData!=null&&oldData.path==path){
|
||||
dataChangeListeners.forEach {
|
||||
it.value.onMusicCompletion(oldData)
|
||||
@@ -153,4 +157,8 @@ object AuditionManager: AuditionCacheManager.DataChangeListener, Audition.OnAudi
|
||||
}
|
||||
}
|
||||
|
||||
fun seekTo(progress: Int) {
|
||||
Audition.seekTo(progress)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user