适配酷我音乐完成
This commit is contained in:
@@ -14,6 +14,8 @@ import com.mogo.module.apps.R;
|
||||
* 基础类:均衡器、方控学习、蓝牙、FM、车载设置、AUX
|
||||
*/
|
||||
public enum AppEnum {
|
||||
// 酷我音乐
|
||||
KwMusic("酷我音乐", "cn.kuwo.kwmusiccar", R.drawable.ic_kuwo),
|
||||
// 爱趣听
|
||||
WeCarFlow("爱趣听","com.tencent.wecarflow", R.drawable.module_apps_ic_we_car_flow ),
|
||||
//"QQ音乐",
|
||||
|
||||
@@ -15,7 +15,8 @@ public class NavigatorApps {
|
||||
|
||||
private static AppInfo app = new AppInfo( "导航", "com.mogo.launcher.navi.search", "", 0, null, R.drawable.module_apps_ic_navigator_navi, 1 );
|
||||
private static AppInfo app_ = new AppInfo( "导航", "com.mogo.launcher.navi.search", "", 0, null, R.drawable.module_apps_ic_navigator_navi_disable, 1 );
|
||||
private static AppInfo app2 = new AppInfo( "音乐", "com.tencent.wecarflow", "", 0, null, R.drawable.module_apps_ic_navigator_media, 2 );
|
||||
// private static AppInfo app2 = new AppInfo( "音乐", "com.tencent.wecarflow", "", 0, null, R.drawable.module_apps_ic_navigator_media, 2 );
|
||||
private static AppInfo app2 = new AppInfo( "音乐", "cn.kuwo.kwmusiccar", "", 0, null, R.drawable.module_apps_ic_navigator_media, 2 );
|
||||
private static AppInfo app3 = new AppInfo( "车聊聊", "com.zhidao.imdemo", "", 0, null, R.drawable.module_apps_ic_navigator_im, 6 );
|
||||
private static AppInfo app4 = new AppInfo( "全部应用", "com.mogo.launcher.applist", "", 0, null, R.drawable.module_apps_ic_navigator_applist, 4 );
|
||||
|
||||
|
||||
BIN
modules/mogo-module-apps/src/main/res/drawable/ic_kuwo.webp
Normal file
BIN
modules/mogo-module-apps/src/main/res/drawable/ic_kuwo.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
@@ -9,7 +9,13 @@
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_map_fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_search_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_map_left_shadow_frame"
|
||||
@@ -48,11 +54,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_search_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_cover_up"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.media.window.MediaWindow2;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
|
||||
@@ -50,4 +50,9 @@ public abstract class BaseMediaPresenter<V extends IView> extends Presenter<V> {
|
||||
* 下一首
|
||||
*/
|
||||
public abstract void next();
|
||||
|
||||
/**
|
||||
* 打开对应的应用
|
||||
*/
|
||||
public abstract void openApp();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.os.Message;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.module.media.MediaConstants;
|
||||
import com.mogo.module.media.constants.MusicConstant;
|
||||
import com.mogo.module.media.model.MediaInfoData;
|
||||
import com.mogo.module.media.view.IMusicView;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
@@ -14,10 +15,10 @@ import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import cn.kuwo.autosdk.api.KWAPI;
|
||||
import cn.kuwo.autosdk.api.OnGetSongImgUrlListener;
|
||||
import cn.kuwo.autosdk.api.PlayState;
|
||||
import cn.kuwo.autosdk.api.PlayerStatus;
|
||||
import cn.kuwo.base.bean.Music;
|
||||
|
||||
/**
|
||||
@@ -30,7 +31,7 @@ public class KwPresenter extends BaseMediaPresenter<IMusicView> {
|
||||
private KWAPI kwapi;
|
||||
private boolean isBind = false;
|
||||
|
||||
private Music currentMusic;
|
||||
private MediaInfoData currentMedia = new MediaInfoData();
|
||||
|
||||
public KwPresenter(IMusicView view) {
|
||||
super(view);
|
||||
@@ -45,35 +46,42 @@ public class KwPresenter extends BaseMediaPresenter<IMusicView> {
|
||||
isBind = b;
|
||||
if (!isBind) {
|
||||
mView.onMusicStopped();
|
||||
}else{
|
||||
PlayerStatus currentState = kwapi.getPlayerStatus();
|
||||
Logger.d(TAG, "check current status: " + currentState);
|
||||
if(currentState == PlayerStatus.BUFFERING||currentState == PlayerStatus.PLAYING){
|
||||
currentMedia.setPlayState(MusicConstant.PLAY_STATE_PLAYING);
|
||||
kwapi.getSongPicUrl(kwapi.getNowPlayingMusic(), onGetSongImgUrlListener);
|
||||
startTrackTrackProgress();
|
||||
mView.onMusicPlaying();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
kwapi.registerExitListener(() -> {
|
||||
Logger.d(TAG, "onExit===");
|
||||
mView.onMusicStopped();
|
||||
mView.onAppExit();
|
||||
});
|
||||
|
||||
kwapi.registerPlayerStatusListener((playerStatus, music) -> {
|
||||
currentMusic = music;
|
||||
MediaInfoData mediaInfoData = new MediaInfoData();
|
||||
mediaInfoData.setMediaName(music.name);
|
||||
mediaInfoData.setMediaImg(music.imageURL);
|
||||
Logger.d(TAG,
|
||||
"onPlayerStatusChange: " + mediaInfoData + " playStatus: " + playerStatus);
|
||||
mView.onMediaInfoChanged(mediaInfoData);
|
||||
Logger.d(TAG, "onPlayerStatusListener: " + playerStatus);
|
||||
switch (playerStatus) {
|
||||
case PLAYING:
|
||||
case BUFFERING:
|
||||
kwapi.getSongPicUrl(music, onGetSongImgUrlListener);
|
||||
break;
|
||||
case PLAYING:
|
||||
currentMedia.setPlayState(MusicConstant.PLAY_STATE_PLAYING);
|
||||
kwapi.getSongPicUrl(music, onGetSongImgUrlListener);
|
||||
startTrackTrackProgress();
|
||||
mView.onMusicPlaying();
|
||||
break;
|
||||
case INIT:
|
||||
case PAUSE:
|
||||
case STOP:
|
||||
currentMedia.setPlayState(MusicConstant.PLAY_STATE_PAUSE_OR_STOP);
|
||||
stopTrackTrackProgress();
|
||||
mView.onMusicPause();
|
||||
break;
|
||||
case STOP:
|
||||
stopTrackTrackProgress();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -101,11 +109,11 @@ public class KwPresenter extends BaseMediaPresenter<IMusicView> {
|
||||
|
||||
@Override
|
||||
public void play(MediaInfoData mediaInfoData) {
|
||||
if (kwapi.isKuwoRunning()) {
|
||||
// if (kwapi.isKuwoRunning()) {
|
||||
kwapi.setPlayState(PlayState.STATE_PLAY);
|
||||
} else {
|
||||
kwapi.randomPlayMusic();
|
||||
}
|
||||
// } else {
|
||||
// kwapi.randomPlayMusic();
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,8 +146,9 @@ public class KwPresenter extends BaseMediaPresenter<IMusicView> {
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if (isTrackingProgress) {
|
||||
mView.onMusicProgress(kwapi.getCurrentMusicDuration(), currentMusic.duration);
|
||||
msg.getTarget().sendEmptyMessageDelayed(MSG_TRACK_PROGRESS, MSG_TRACK_PROGRESS_DELAY);
|
||||
mView.onMusicProgress(kwapi.getCurrentPos(), kwapi.getCurrentMusicDuration());
|
||||
msg.getTarget().sendEmptyMessageDelayed(MSG_TRACK_PROGRESS,
|
||||
MSG_TRACK_PROGRESS_DELAY);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -151,12 +160,37 @@ public class KwPresenter extends BaseMediaPresenter<IMusicView> {
|
||||
private boolean isTrackingProgress = false;
|
||||
|
||||
private void startTrackTrackProgress() {
|
||||
isTrackingProgress = true;
|
||||
handler.sendEmptyMessageDelayed(MSG_TRACK_PROGRESS, MSG_TRACK_PROGRESS_DELAY);
|
||||
if(!isTrackingProgress) {
|
||||
isTrackingProgress = true;
|
||||
handler.sendEmptyMessageDelayed(MSG_TRACK_PROGRESS, MSG_TRACK_PROGRESS_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopTrackTrackProgress() {
|
||||
isTrackingProgress = false;
|
||||
handler.removeMessages(MSG_TRACK_PROGRESS);
|
||||
if(isTrackingProgress) {
|
||||
isTrackingProgress = false;
|
||||
handler.removeMessages(MSG_TRACK_PROGRESS);
|
||||
}
|
||||
}
|
||||
|
||||
private OnGetSongImgUrlListener onGetSongImgUrlListener = new OnGetSongImgUrlListener() {
|
||||
@Override
|
||||
public void onGetSongImgUrlSucessed(Music music, String s) {
|
||||
currentMedia.setMediaName(music.name);
|
||||
currentMedia.setMediaImg(s);
|
||||
Logger.d(TAG,
|
||||
"onGetSongImgUrlSucessed: " + currentMedia);
|
||||
handler.post(() -> mView.onMediaInfoChanged(currentMedia));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetSongImgUrlFailed(Music music, int i) {
|
||||
Logger.e(TAG, "onGetSongImgUrlFailed: " + i);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void openApp(){
|
||||
kwapi.startAPP(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,4 +195,9 @@ public class WeCarFlowPresenter extends BaseMediaPresenter<IMusicView> {
|
||||
public void next() {
|
||||
FlowPlayControl.getInstance().doNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openApp() {
|
||||
FlowPlayControl.getInstance().startPlayActivity(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,6 @@ public interface IMusicView extends IView {
|
||||
void onMusicStopped();
|
||||
|
||||
void onMusicProgress(long current,long total);
|
||||
|
||||
void onAppExit();
|
||||
}
|
||||
|
||||
@@ -79,7 +79,9 @@ public class AnimCircleImageView extends ImageView {
|
||||
}
|
||||
|
||||
public void startAnim() {
|
||||
if (isRotating == true) return;
|
||||
if (isRotating){
|
||||
return;
|
||||
}
|
||||
isRotateEnable = true;
|
||||
isRotating = true;
|
||||
currentDegree = savedDegree;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.module.media;
|
||||
package com.mogo.module.media.window;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -8,12 +8,14 @@ import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.module.common.entity.MarkerShareMusic;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.media.MediaConstants;
|
||||
import com.mogo.module.media.R;
|
||||
import com.mogo.module.media.ServiceMediaHandler;
|
||||
import com.mogo.module.media.constants.LeTingFieldConstants;
|
||||
import com.mogo.module.media.constants.QQMusicFieldConstants;
|
||||
import com.mogo.module.media.listener.NoDoubleClickListener;
|
||||
@@ -30,7 +32,6 @@ import com.mogo.module.media.view.MediaView;
|
||||
import com.mogo.module.media.widget.AnimCircleImageView;
|
||||
import com.mogo.module.media.widget.NoScrollSeekBar;
|
||||
import com.mogo.module.media.widget.ScrollingTextView;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.utils.ActivityLifecycleManager;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
@@ -65,15 +66,9 @@ public class MediaWindow implements MediaView{
|
||||
private boolean mTwoChange = false;
|
||||
private boolean isFirstPlay = false;
|
||||
|
||||
private Runnable mRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MusicControlBroadCast.sendGetMusicPlayStateBroadcast();
|
||||
}
|
||||
};
|
||||
private Runnable mRunnable = MusicControlBroadCast::sendGetMusicPlayStateBroadcast;
|
||||
|
||||
public void initMedia(Context context){
|
||||
|
||||
mContext = context;
|
||||
mPresenter = new MediaPresenter(this);
|
||||
registerMediaReceiver();
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mogo.module.media;
|
||||
package com.mogo.module.media.window;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
@@ -11,18 +10,17 @@ import android.widget.TextView;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.module.media.R;
|
||||
import com.mogo.module.media.ServiceMediaHandler;
|
||||
import com.mogo.module.media.constants.MusicConstant;
|
||||
import com.mogo.module.media.listener.NoDoubleClickListener;
|
||||
import com.mogo.module.media.model.MediaInfoData;
|
||||
import com.mogo.module.media.presenter.BaseMediaPresenter;
|
||||
import com.mogo.module.media.presenter.KwPresenter;
|
||||
import com.mogo.module.media.presenter.WeCarFlowPresenter;
|
||||
import com.mogo.module.media.utils.Utils;
|
||||
import com.mogo.module.media.view.IMusicView;
|
||||
import com.mogo.module.media.widget.AnimCircleImageView;
|
||||
import com.mogo.module.media.widget.NoScrollSeekBar;
|
||||
import com.mogo.module.media.widget.ScrollingTextView;
|
||||
import com.mogo.utils.LaunchUtils;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
import com.mogo.utils.glide.GlideApp;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -110,7 +108,7 @@ public class MediaWindow2 implements IMusicView {
|
||||
mWindowView.setOnClickListener(new NoDoubleClickListener() {
|
||||
@Override
|
||||
public void onClicks(View view) {
|
||||
openAqtApp();
|
||||
mPresenter.openApp();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -125,7 +123,7 @@ public class MediaWindow2 implements IMusicView {
|
||||
mPresenter.pause(mMediaInfoData);
|
||||
}
|
||||
} else {
|
||||
openAqtApp();
|
||||
mPresenter.openApp();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -171,6 +169,16 @@ public class MediaWindow2 implements IMusicView {
|
||||
if (mWindowCurrTime != null) {
|
||||
mWindowCurrTime.setText(Utils.calculateTime((int) mMediaInfoData.getCurTime()));
|
||||
}
|
||||
|
||||
if( mMediaInfoData.getPlayState() == MusicConstant.PLAY_STATE_PLAYING) {
|
||||
// kw音乐做的容错
|
||||
if (mWindowPlayPause != null) {
|
||||
mWindowPlayPause.setImageResource(R.drawable.module_media_window_pop_play);
|
||||
}
|
||||
if (mCircleImg != null) {
|
||||
mCircleImg.startAnim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mCircleImg != null) {
|
||||
@@ -257,11 +265,8 @@ public class MediaWindow2 implements IMusicView {
|
||||
}
|
||||
}
|
||||
|
||||
private void openAqtApp() {
|
||||
try {
|
||||
LaunchUtils.launchByPkg(mContext, "com.tencent.wecarflow");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@Override
|
||||
public void onAppExit() {
|
||||
mWindowView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user