update
This commit is contained in:
parent
7bcfa1b3b8
commit
c1aa62c693
@ -75,6 +75,7 @@ import java.util.concurrent.TimeUnit
|
|||||||
abstract class MoBaseActivity : AppCompatActivity(), MusicPlayerView.PlaySkipForwardListener,
|
abstract class MoBaseActivity : AppCompatActivity(), MusicPlayerView.PlaySkipForwardListener,
|
||||||
CoroutineScope by MainScope(), LifecycleOwner {
|
CoroutineScope by MainScope(), LifecycleOwner {
|
||||||
private var playerListener: Player.Listener? = null
|
private var playerListener: Player.Listener? = null
|
||||||
|
private var currentLayoutId: LinearLayout? = null
|
||||||
|
|
||||||
enum class Event {
|
enum class Event {
|
||||||
ActivityStart, ActivityStop, ActivityOnResume, AutomaticallySwitchSongs,
|
ActivityStart, ActivityStop, ActivityOnResume, AutomaticallySwitchSongs,
|
||||||
@ -136,7 +137,11 @@ abstract class MoBaseActivity : AppCompatActivity(), MusicPlayerView.PlaySkipFor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addMusicPlayerViewToLayout(layoutId: LinearLayout) {
|
fun addMusicPlayerViewToLayout(layoutId: LinearLayout?) {
|
||||||
|
if (layoutId == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
currentLayoutId = layoutId
|
||||||
if (meController != null && meController.mediaItemCount > 0 && meController.duration > 0) {
|
if (meController != null && meController.mediaItemCount > 0 && meController.duration > 0) {
|
||||||
if (layoutId.childCount <= 0) {//没有添加view才进行添加
|
if (layoutId.childCount <= 0) {//没有添加view才进行添加
|
||||||
layoutId.addView(musicPlayerView)
|
layoutId.addView(musicPlayerView)
|
||||||
@ -173,20 +178,22 @@ abstract class MoBaseActivity : AppCompatActivity(), MusicPlayerView.PlaySkipFor
|
|||||||
override fun onPositionDiscontinuity(
|
override fun onPositionDiscontinuity(
|
||||||
oldPosition: Player.PositionInfo, newPosition: Player.PositionInfo, reason: Int
|
oldPosition: Player.PositionInfo, newPosition: Player.PositionInfo, reason: Int
|
||||||
) {
|
) {
|
||||||
LogTag.LogD(TAG,"reason->$reason")
|
LogTag.LogD(TAG, "reason->$reason")
|
||||||
if (reason == Player.DISCONTINUITY_REASON_AUTO_TRANSITION
|
if (reason == Player.DISCONTINUITY_REASON_AUTO_TRANSITION || reason == Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT) {
|
||||||
|| reason == Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT) {
|
|
||||||
if (meController != null) {
|
if (meController != null) {
|
||||||
musicPlayerView.updateInfoUi(meController.currentMediaItem)
|
musicPlayerView.updateInfoUi(meController.currentMediaItem)
|
||||||
musicPlayerView.updateSetProgress(meController)
|
musicPlayerView.updateSetProgress(meController)
|
||||||
musicPlayerView.updateProgressState(meController)
|
musicPlayerView.updateProgressState(meController)
|
||||||
}
|
}
|
||||||
LogTag.LogD(TAG,"reason update")
|
LogTag.LogD(TAG, "reason update")
|
||||||
events.trySend(Event.AutomaticallySwitchSongs)
|
events.trySend(Event.AutomaticallySwitchSongs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPlaybackStateChanged(playbackState: Int) {
|
override fun onPlaybackStateChanged(playbackState: Int) {
|
||||||
|
if (currentLayoutId != null) {
|
||||||
|
addMusicPlayerViewToLayout(currentLayoutId)
|
||||||
|
}
|
||||||
val meController = MediaControllerManager.getController()
|
val meController = MediaControllerManager.getController()
|
||||||
if (meController != null) {
|
if (meController != null) {
|
||||||
musicPlayerView.updateProgressState(meController)
|
musicPlayerView.updateProgressState(meController)
|
||||||
@ -526,7 +533,7 @@ abstract class MoBaseActivity : AppCompatActivity(), MusicPlayerView.PlaySkipFor
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun showRatingDialog() {
|
fun showRatingDialog() {
|
||||||
val intervalTime = 1000 * 60 * 5
|
val intervalTime = 1000 * 60 * 60 * 24 * 3
|
||||||
val dialog = RatingDialog(this)
|
val dialog = RatingDialog(this)
|
||||||
val installTime = appStore.showRateDialogTime
|
val installTime = appStore.showRateDialogTime
|
||||||
val currentTime = System.currentTimeMillis()
|
val currentTime = System.currentTimeMillis()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user