This commit is contained in:
tongchenfei
2020-07-02 13:18:58 +08:00
parent 0c9efb1f7c
commit 307e0aed8a

View File

@@ -3,6 +3,7 @@ package com.mogo.module.media.presenter;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.module.media.MediaConstants;
@@ -43,12 +44,14 @@ public class KwPresenter extends BaseMediaPresenter<IMusicView> {
kwapi.registerConnectedListener(b -> {
Logger.d(TAG, "onConnected: " + b);
Log.d(TAG, "onConnected: " + b);
isBind = b;
if (!isBind) {
mView.onMusicStopped();
}else{
PlayerStatus currentState = kwapi.getPlayerStatus();
Logger.d(TAG, "check current status: " + currentState);
Log.d(TAG, "check current status: " + currentState);
if(currentState == PlayerStatus.BUFFERING||currentState == PlayerStatus.PLAYING){
currentMedia.setPlayState(MusicConstant.PLAY_STATE_PLAYING);
kwapi.getSongPicUrl(kwapi.getNowPlayingMusic(), onGetSongImgUrlListener);
@@ -60,11 +63,13 @@ public class KwPresenter extends BaseMediaPresenter<IMusicView> {
kwapi.registerExitListener(() -> {
Logger.d(TAG, "onExit===");
Log.d(TAG, "onExit===");
mView.onAppExit();
});
kwapi.registerPlayerStatusListener((playerStatus, music) -> {
Logger.d(TAG, "onPlayerStatusListener: " + playerStatus);
Log.d(TAG, "onPlayerStatusListener: " + playerStatus);
switch (playerStatus) {
case BUFFERING:
kwapi.getSongPicUrl(music, onGetSongImgUrlListener);
@@ -95,6 +100,7 @@ public class KwPresenter extends BaseMediaPresenter<IMusicView> {
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
if (isTrue) {
Logger.d(TAG, "onResume, isBind: " + isBind);
Log.d(TAG, "onResume, isBind: " + isBind);
// 需要在resume时候判断绑定关系是否正常
if (!isBind) {
// 未绑定,需要重新绑定,同时第一次绑定初始化也是在此处