Merge branch 'dev_aqt' into dev
This commit is contained in:
@@ -55,7 +55,7 @@ android {
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
manifest.srcFile 'src/independent/AndroidManifest.xml'
|
||||
manifest.srcFile 'src/main/AndroidManifest.xml'
|
||||
}
|
||||
launcher {
|
||||
manifest.srcFile 'src/launcher/AndroidManifest.xml'
|
||||
|
||||
@@ -14,7 +14,8 @@ import com.mogo.module.apps.R;
|
||||
* 基础类:均衡器、方控学习、蓝牙、FM、车载设置、AUX
|
||||
*/
|
||||
public enum AppEnum {
|
||||
|
||||
// 爱趣听
|
||||
WeCarFlow("爱趣听","com.tencent.wecarflow", R.drawable.module_apps_ic_we_car_flow ),
|
||||
//"QQ音乐",
|
||||
QQMusic( "QQ音乐", "com.pvetec.musics", R.drawable.module_apps_ic_qq_music ),
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
@@ -35,7 +35,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation fileTree(dir: 'libs', include: ['*.aar'])
|
||||
|
||||
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
|
||||
Binary file not shown.
@@ -8,6 +8,7 @@
|
||||
<uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" />
|
||||
<uses-permission android:name="android.permission.TYPE_APPLICATION_OVERLAY" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||
<uses-permission android:name="com.tencent.wecarflow.PLAY_CONTROL" />
|
||||
|
||||
<application>
|
||||
<receiver android:name=".receiver.MediaSpeechReceiver">
|
||||
|
||||
@@ -14,15 +14,12 @@ import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@Route( path = MediaConstants.TAG )
|
||||
public class MediaCardViewProvider implements IMogoModuleProvider {
|
||||
|
||||
private static final String TAG = "MediaCardViewProvider";
|
||||
|
||||
private MediaWindow mMediaWindow;
|
||||
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( Context context, Bundle data ) {
|
||||
@@ -35,10 +32,8 @@ public class MediaCardViewProvider implements IMogoModuleProvider {
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
ServiceMediaHandler.init( context );
|
||||
|
||||
mMediaWindow = new MediaWindow();
|
||||
mMediaWindow.initMedia(context);
|
||||
|
||||
MediaWindow2 mediaWindow2 = new MediaWindow2();
|
||||
mediaWindow2.initMedia(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -181,8 +181,12 @@ public class MediaWindow implements MediaView{
|
||||
}
|
||||
|
||||
if (first || mMediaInfoData.getPlayState() == 1 || mMediaInfoData.getPlayState() == 2) {
|
||||
if (mWindowMaxTime != null) mWindowMaxTime.setText(Utils.calculateTime((int) mMediaInfoData.getMaxTime()));
|
||||
if (mWindowCurrTime != null) mWindowCurrTime.setText(Utils.calculateTime((int) mMediaInfoData.getCurTime()));
|
||||
if (mWindowMaxTime != null){
|
||||
mWindowMaxTime.setText(Utils.calculateTime((int) mMediaInfoData.getMaxTime()));
|
||||
}
|
||||
if (mWindowCurrTime != null){
|
||||
mWindowCurrTime.setText(Utils.calculateTime((int) mMediaInfoData.getCurTime()));
|
||||
}
|
||||
}
|
||||
|
||||
if (mCircleImg != null){
|
||||
@@ -286,7 +290,9 @@ public class MediaWindow implements MediaView{
|
||||
}
|
||||
|
||||
|
||||
if (mCircleImg != null) mCircleImg.stopAnim();
|
||||
if (mCircleImg != null){
|
||||
mCircleImg.stopAnim();
|
||||
}
|
||||
|
||||
if (type == 1 || type == 2 || type ==3){
|
||||
UiThreadHandler.removeCallbacks(mRunnable);
|
||||
@@ -417,10 +423,18 @@ public class MediaWindow implements MediaView{
|
||||
bookid = leTingNewsData.getSid();
|
||||
}
|
||||
|
||||
if (mediaName == null) mediaName = "";
|
||||
if (artist == null) artist = "";
|
||||
if (cover == null) cover = "";
|
||||
if (bookid == null) bookid = "";
|
||||
if (mediaName == null){
|
||||
mediaName = "";
|
||||
}
|
||||
if (artist == null){
|
||||
artist = "";
|
||||
}
|
||||
if (cover == null){
|
||||
cover = "";
|
||||
}
|
||||
if (bookid == null){
|
||||
bookid = "";
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
package com.mogo.module.media;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
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.WeCarFlowPresenter;
|
||||
import com.mogo.module.media.utils.LaunchUtils;
|
||||
import com.mogo.module.media.utils.MusicControlBroadCast;
|
||||
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.TipToast;
|
||||
import com.mogo.utils.glide.GlideApp;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* 适配爱趣听的window
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class MediaWindow2 implements IMusicView {
|
||||
|
||||
public static final String TAG = MediaWindow2.class.getName();
|
||||
private Context mContext;
|
||||
private WeCarFlowPresenter mPresenter;
|
||||
|
||||
private MediaInfoData mMediaInfoData = new MediaInfoData();
|
||||
|
||||
private View mWindowView;
|
||||
private AnimCircleImageView mCircleImg;
|
||||
private ScrollingTextView mScrollText;
|
||||
private ImageView mWindowPlayPause;
|
||||
private ImageView mWindowPlayNext;
|
||||
private LinearLayout mWindowMediaCenter;
|
||||
private TextView mWindowCurrTime;
|
||||
private TextView mWindowMaxTime;
|
||||
private NoScrollSeekBar mWindowProgress;
|
||||
|
||||
private boolean mHasAddWindow = false;
|
||||
private boolean mTwoChange = false;
|
||||
private boolean isFirstPlay = false;
|
||||
|
||||
public void initMedia(Context context) {
|
||||
mContext = context;
|
||||
mPresenter = new WeCarFlowPresenter(this);
|
||||
mPresenter.init(context);
|
||||
|
||||
isFirstPlay = true;
|
||||
}
|
||||
|
||||
private void addWindowView() {
|
||||
if (ServiceMediaHandler.getMogoWindowManager() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mHasAddWindow) {
|
||||
mHasAddWindow = true;
|
||||
mWindowView =
|
||||
LayoutInflater.from(mContext).inflate(R.layout.module_media_music_window_alert_layout, null);
|
||||
mWindowView.setVisibility(View.VISIBLE);
|
||||
mCircleImg = mWindowView.findViewById(R.id.window_circle_img);
|
||||
mScrollText = mWindowView.findViewById(R.id.window_scroll_txt);
|
||||
mWindowPlayPause = mWindowView.findViewById(R.id.window_play_pause);
|
||||
mWindowPlayNext = mWindowView.findViewById(R.id.window_music_next);
|
||||
mWindowMediaCenter = mWindowView.findViewById(R.id.window_media_center);
|
||||
mWindowCurrTime = mWindowView.findViewById(R.id.window_current_time);
|
||||
mWindowMaxTime = mWindowView.findViewById(R.id.window_max_time);
|
||||
mWindowProgress = mWindowView.findViewById(R.id.window_progress_bar);
|
||||
if (mWindowPlayPause != null) {
|
||||
mWindowPlayPause.setImageResource(R.drawable.module_media_window_pop_pause);
|
||||
}
|
||||
int yPos =
|
||||
getContext().getResources().getDimensionPixelOffset(R.dimen.module_media_music_state_location);
|
||||
int xPos =
|
||||
getContext().getResources().getDimensionPixelOffset(R.dimen.module_media_music_state_location_x);
|
||||
ServiceMediaHandler.getMogoWindowManager().addView(mWindowView, xPos, yPos, false);
|
||||
updateWindowUI(true);
|
||||
mWindowMediaCenter.setOnClickListener(new NoDoubleClickListener() {
|
||||
@Override
|
||||
public void onClicks(View view) {
|
||||
openAqtApp();
|
||||
}
|
||||
});
|
||||
|
||||
mWindowPlayPause.setOnClickListener(new NoDoubleClickListener() {
|
||||
@Override
|
||||
public void onClicks(View view) {
|
||||
if (mMediaInfoData != null) {
|
||||
if (mMediaInfoData.getPlayState() == MusicConstant.PLAY_STATE_PAUSE_OR_STOP) {
|
||||
mPresenter.play(mMediaInfoData);
|
||||
} else {
|
||||
// 没有做详细判断,不是暂停就是播放
|
||||
mPresenter.pause(mMediaInfoData);
|
||||
}
|
||||
} else {
|
||||
openAqtApp();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mWindowPlayNext.setOnClickListener(new NoDoubleClickListener() {
|
||||
@Override
|
||||
public void onClicks(View view) {
|
||||
if (mPresenter != null) {
|
||||
mPresenter.next();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void updateWindowUI() {
|
||||
updateWindowUI(false);
|
||||
}
|
||||
|
||||
private void updateWindowUI(boolean first) {
|
||||
if (mWindowView == null) {
|
||||
return;
|
||||
}
|
||||
if (mMediaInfoData != null) {
|
||||
if (mMediaInfoData.getType() == MusicConstant.PLAY_STATE_ERROR||isFirstPlay) {
|
||||
mWindowView.setVisibility(View.GONE);
|
||||
} else {
|
||||
mWindowView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
mWindowView.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mScrollText != null) {
|
||||
mScrollText.setText(mMediaInfoData.getMediaName());
|
||||
}
|
||||
|
||||
if (first || mMediaInfoData.getPlayState() == MusicConstant.PLAY_STATE_PLAYING || mMediaInfoData.getPlayState() == MusicConstant.PLAY_STATE_BUFF) {
|
||||
if (mWindowMaxTime != null) {
|
||||
mWindowMaxTime.setText(Utils.calculateTime((int) mMediaInfoData.getMaxTime()));
|
||||
}
|
||||
if (mWindowCurrTime != null) {
|
||||
mWindowCurrTime.setText(Utils.calculateTime((int) mMediaInfoData.getCurTime()));
|
||||
}
|
||||
}
|
||||
|
||||
if (mCircleImg != null) {
|
||||
com.bumptech.glide.request.RequestOptions options =
|
||||
new com.bumptech.glide.request.RequestOptions()
|
||||
.placeholder(R.drawable.module_media_share_default_icon);
|
||||
GlideApp.with(mContext).applyDefaultRequestOptions(options).load(mMediaInfoData.getMediaImg()).into(mCircleImg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMusicPlaying() {
|
||||
Logger.d(TAG, "onMusicPlaying===" + mMediaInfoData);
|
||||
isFirstPlay = false;
|
||||
updateWindowUI(false);
|
||||
if (mWindowPlayPause != null) {
|
||||
mWindowPlayPause.setImageResource(R.drawable.module_media_window_pop_play);
|
||||
}
|
||||
|
||||
if (mCircleImg != null) {
|
||||
mCircleImg.startAnim();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMusicPause() {
|
||||
Logger.d(TAG, "onMusicPause: ===" + mMediaInfoData);
|
||||
if (mWindowPlayPause != null) {
|
||||
mWindowPlayPause.setImageResource(R.drawable.module_media_window_pop_pause);
|
||||
}
|
||||
|
||||
if (mCircleImg != null) {
|
||||
mCircleImg.stopAnim();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMusicStopped() {
|
||||
Logger.d(TAG, "onMusicStopped===" + mMediaInfoData);
|
||||
if (mWindowPlayPause != null) {
|
||||
mWindowPlayPause.setImageResource(R.drawable.module_media_window_pop_pause);
|
||||
}
|
||||
|
||||
if (mCircleImg != null) {
|
||||
mCircleImg.stopAnim();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMediaInfoChanged(MediaInfoData mediaInfoData) {
|
||||
Logger.d(TAG, "onMediaInfoChanged: " + mediaInfoData);
|
||||
mMediaInfoData = mediaInfoData;
|
||||
addWindowView();
|
||||
updateWindowUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMusicProgress(long current, long total) {
|
||||
// Logger.d(TAG, "onMusicProgress==current: " + current + " total: " + total);
|
||||
if (mMediaInfoData != null) {
|
||||
mMediaInfoData.setCurTime((int) current);
|
||||
mMediaInfoData.setMaxTime((int) total);
|
||||
}
|
||||
if (mWindowCurrTime != null) {
|
||||
mWindowCurrTime.setText(Utils.calculateTime((int) current));
|
||||
mWindowMaxTime.setText(Utils.calculateTime((int) total));
|
||||
}
|
||||
try {
|
||||
int progress =
|
||||
(int) ((current * 1.0f * 100) / (total * 1.0f));
|
||||
if (mWindowProgress != null) {
|
||||
mWindowProgress.setProgress(progress);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void openAqtApp() {
|
||||
try {
|
||||
LaunchUtils.launchByPkg(mContext, "com.tencent.wecarflow");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.module.media.constants;
|
||||
|
||||
/**
|
||||
* 音频相关常量
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class MusicConstant {
|
||||
public static final int PLAY_STATE_PLAYING = 1;
|
||||
public static final int PLAY_STATE_BUFF = 2;
|
||||
public static final int PLAY_STATE_PAUSE_OR_STOP = 0;
|
||||
public static final int PLAY_STATE_ERROR = -1;
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.module.media.model;
|
||||
|
||||
import com.mogo.module.media.constants.MusicConstant;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MediaInfoData implements Serializable {
|
||||
@@ -142,4 +144,13 @@ public class MediaInfoData implements Serializable {
|
||||
public void setBookInfo(String bookInfo) {
|
||||
this.bookInfo = bookInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MediaInfoData{" +
|
||||
"mediaName='" + mediaName + '\'' +
|
||||
", mediaImg='" + mediaImg + '\'' +
|
||||
", playState=" + playState +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.mogo.module.media.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.module.media.model.MediaInfoData;
|
||||
|
||||
/**
|
||||
* 媒体播放presenter基类,目前没有整合到原MediaPresenter中,原来的qq音乐,喜马拉雅和懒人听书下掉了
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public abstract class BaseMediaPresenter<V extends IView> extends Presenter<V> {
|
||||
public BaseMediaPresenter(V view) {
|
||||
super(view);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
* @param context 上下文
|
||||
*/
|
||||
public abstract void init(Context context);
|
||||
|
||||
/**
|
||||
* 播放音乐
|
||||
* @param mediaInfoData 待播放音乐信息
|
||||
*/
|
||||
public abstract void play(MediaInfoData mediaInfoData);
|
||||
|
||||
/**
|
||||
* 暂停播放
|
||||
* @param mediaInfoData 待暂停音乐信息
|
||||
*/
|
||||
public abstract void pause(MediaInfoData mediaInfoData);
|
||||
|
||||
/**
|
||||
* 停止播放
|
||||
* @param mediaInfoData 待停止播放音乐信息
|
||||
*/
|
||||
public abstract void stop(MediaInfoData mediaInfoData);
|
||||
|
||||
/**
|
||||
* 上一首
|
||||
*/
|
||||
public abstract void pre();
|
||||
|
||||
/**
|
||||
* 下一首
|
||||
*/
|
||||
public abstract void next();
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package com.mogo.module.media.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
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;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.tencent.wecarflow.flowoutside.sdk.BindListener;
|
||||
import com.tencent.wecarflow.flowoutside.sdk.FlowPlayControl;
|
||||
import com.tencent.wecarflow.flowoutside.sdk.MediaChangeListener;
|
||||
import com.tencent.wecarflow.flowoutside.sdk.MediaInfo;
|
||||
import com.tencent.wecarflow.flowoutside.sdk.PlayStateListener;
|
||||
import com.tencent.wecarflow.flowoutside.sdk.QueryCallback;
|
||||
|
||||
/**
|
||||
* 爱趣听presenter
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class WeCarFlowPresenter extends BaseMediaPresenter<IMusicView> {
|
||||
private static final String TAG = "WeCarFlowPresenter";
|
||||
public WeCarFlowPresenter(IMusicView view) {
|
||||
super(view);
|
||||
}
|
||||
|
||||
private Context context;
|
||||
|
||||
private MediaInfoData currentMedia;
|
||||
|
||||
private boolean isBind = true;
|
||||
private IMogoServiceApis serviceApis;
|
||||
|
||||
private QueryCallback<Boolean> isPlayingCallback = new QueryCallback<Boolean>() {
|
||||
@Override
|
||||
public void onError(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Boolean aBoolean) {
|
||||
currentMedia.setPlayState(aBoolean ? MusicConstant.PLAY_STATE_PLAYING :
|
||||
MusicConstant.PLAY_STATE_PAUSE_OR_STOP);
|
||||
if (mView != null) {
|
||||
mView.onMediaInfoChanged(currentMedia);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private QueryCallback<MediaInfo> currentCallback = new QueryCallback<MediaInfo>() {
|
||||
@Override
|
||||
public void onError(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(MediaInfo mediaInfo) {
|
||||
currentMedia.setMediaName(mediaInfo.getMediaName());
|
||||
currentMedia.setMediaImg(mediaInfo.getMediaImage());
|
||||
if (mView != null) {
|
||||
mView.onMediaInfoChanged(currentMedia);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
this.context = context;
|
||||
currentMedia = new MediaInfoData();
|
||||
|
||||
serviceApis =
|
||||
(IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
|
||||
|
||||
serviceApis.getStatusManagerApi().registerStatusChangedListener(MediaConstants.MODULE_TYPE, StatusDescriptor.MAIN_PAGE_RESUME, new IMogoStatusChangedListener() {
|
||||
@Override
|
||||
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
|
||||
if (isTrue) {
|
||||
Logger.d(TAG, "onResume, isBind: " + isBind);
|
||||
// 需要在resume时候判断绑定关系是否正常
|
||||
if (!isBind) {
|
||||
// 未绑定,需要重新绑定,同时第一次绑定初始化也是在此处
|
||||
FlowPlayControl.getInstance().bindPlayService(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FlowPlayControl.getInstance().addBindListener(new BindListener() {
|
||||
@Override
|
||||
public void onServiceConnected() {
|
||||
Logger.d(TAG, "onServiceConnected===");
|
||||
isBind = true;
|
||||
FlowPlayControl.getInstance().queryPlaying(isPlayingCallback);
|
||||
FlowPlayControl.getInstance().queryCurrent(currentCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected() {
|
||||
Logger.e(TAG, "onServiceDisconnected===");
|
||||
isBind = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindDied() {
|
||||
Logger.e(TAG, "onBindDied===");
|
||||
isBind = false;
|
||||
}
|
||||
});
|
||||
|
||||
FlowPlayControl.getInstance().addMediaChangeListener(new MediaChangeListener() {
|
||||
@Override
|
||||
public void onMediaChange(MediaInfo mediaInfo) {
|
||||
Logger.d(TAG, "onMediaChange: " + mediaInfo);
|
||||
Logger.d(TAG, "onMediaChange, img: " + mediaInfo.getMediaImage());
|
||||
currentMedia.setMediaName(mediaInfo.getMediaName());
|
||||
currentMedia.setMediaImg(mediaInfo.getMediaImage());
|
||||
mView.onMediaInfoChanged(currentMedia);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFavorChange(boolean b) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
FlowPlayControl.getInstance().addPlayStateListener(new PlayStateListener() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
if (mView != null && currentMedia != null) {
|
||||
currentMedia.setPlayState(MusicConstant.PLAY_STATE_PLAYING);
|
||||
mView.onMusicPlaying();
|
||||
mView.onMediaInfoChanged(currentMedia);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (mView != null && currentMedia != null) {
|
||||
currentMedia.setPlayState(MusicConstant.PLAY_STATE_PAUSE_OR_STOP);
|
||||
mView.onMusicPause();
|
||||
mView.onMediaInfoChanged(currentMedia);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
if (mView != null && currentMedia != null) {
|
||||
currentMedia.setPlayState(MusicConstant.PLAY_STATE_PAUSE_OR_STOP);
|
||||
mView.onMusicStopped();
|
||||
mView.onMediaInfoChanged(currentMedia);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(String s, long current, long total) {
|
||||
if (mView != null) {
|
||||
mView.onMusicProgress(current, total);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FlowPlayControl.getInstance().bindPlayService(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void play(MediaInfoData mediaInfoData) {
|
||||
FlowPlayControl.getInstance().doPlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause(MediaInfoData mediaInfoData) {
|
||||
FlowPlayControl.getInstance().doPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(MediaInfoData mediaInfoData) {
|
||||
FlowPlayControl.getInstance().doStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pre() {
|
||||
FlowPlayControl.getInstance().doPre();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void next() {
|
||||
FlowPlayControl.getInstance().doNext();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.mogo.module.media.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-02-03
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class LaunchUtils {
|
||||
|
||||
/**
|
||||
* 通过包名启动app
|
||||
*
|
||||
* @param context
|
||||
* @param pkg 包名
|
||||
*/
|
||||
public static void launchByPkg( Context context, String pkg ) throws Exception {
|
||||
Intent intent = getLaunchIntentForPackage( context, pkg );
|
||||
intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
|
||||
context.startActivity( intent );
|
||||
}
|
||||
|
||||
public static Intent getLaunchIntentForPackage( Context context, String pkg ) {
|
||||
return context.getPackageManager().getLaunchIntentForPackage( pkg );
|
||||
}
|
||||
}
|
||||
@@ -459,21 +459,23 @@ public class MusicControlBroadCast {
|
||||
}
|
||||
}
|
||||
|
||||
// return null;
|
||||
MediaInfoData mediaInfoData = new MediaInfoData();
|
||||
mediaInfoData.setMediaId("001jiOrk2g389Y");
|
||||
mediaInfoData.setBookInfo("");
|
||||
mediaInfoData.setType(1);
|
||||
mediaInfoData.setMediaName("恭喜发财 (广场舞)");
|
||||
mediaInfoData.setMediaSinger("刘德华");
|
||||
mediaInfoData.setMediaType("物流派");
|
||||
mediaInfoData.setPlayState(0);
|
||||
mediaInfoData.setLocalMedia(false);
|
||||
mediaInfoData.setCurTime(0);
|
||||
mediaInfoData.setMaxTime(410*1000);
|
||||
mediaInfoData.setMediaUrl("http://isure.stream.qqmusic.qq.com/C200000s2wCd3pzdnA.m4a?guid=2000001271&vkey=8CE1A876F5079A6E4E9BCB8306252EF152F3D4F237B3BF4C1450B50BA7E065D3D55A0735FD2E957B129E83FF7D7D5D398479D53FE2171DF0&uin=&fromtag=50");
|
||||
mediaInfoData.setMediaImg("http://music.qq.com/musicbox/img/uccpic_error.jpg");
|
||||
return mediaInfoData;//刘德华的恭喜发财
|
||||
return null;
|
||||
|
||||
// 测试代码吧?
|
||||
// MediaInfoData mediaInfoData = new MediaInfoData();
|
||||
// mediaInfoData.setMediaId("001jiOrk2g389Y");
|
||||
// mediaInfoData.setBookInfo("");
|
||||
// mediaInfoData.setType(1);
|
||||
// mediaInfoData.setMediaName("恭喜发财 (广场舞)");
|
||||
// mediaInfoData.setMediaSinger("刘德华");
|
||||
// mediaInfoData.setMediaType("物流派");
|
||||
// mediaInfoData.setPlayState(0);
|
||||
// mediaInfoData.setLocalMedia(false);
|
||||
// mediaInfoData.setCurTime(0);
|
||||
// mediaInfoData.setMaxTime(410*1000);
|
||||
// mediaInfoData.setMediaUrl("http://isure.stream.qqmusic.qq.com/C200000s2wCd3pzdnA.m4a?guid=2000001271&vkey=8CE1A876F5079A6E4E9BCB8306252EF152F3D4F237B3BF4C1450B50BA7E065D3D55A0735FD2E957B129E83FF7D7D5D398479D53FE2171DF0&uin=&fromtag=50");
|
||||
// mediaInfoData.setMediaImg("http://music.qq.com/musicbox/img/uccpic_error.jpg");
|
||||
// return mediaInfoData;//刘德华的恭喜发财
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.mogo.module.media.view;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.module.media.model.MediaInfoData;
|
||||
|
||||
/**
|
||||
* 音频显示类的接口
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public interface IMusicView extends IView {
|
||||
void onMediaInfoChanged(MediaInfoData mediaInfoData);
|
||||
|
||||
void onMusicPlaying();
|
||||
|
||||
void onMusicPause();
|
||||
|
||||
void onMusicStopped();
|
||||
|
||||
void onMusicProgress(long current,long total);
|
||||
}
|
||||
Reference in New Issue
Block a user