房间播放背景音乐增加单曲循环和全部循环切换功能
This commit is contained in:
@@ -21,6 +21,7 @@ import com.yizhuan.erban.R;
|
|||||||
import com.yizhuan.erban.base.BaseMvpActivity;
|
import com.yizhuan.erban.base.BaseMvpActivity;
|
||||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
||||||
import com.yizhuan.tutu.music.activity.MusicListActivity;
|
import com.yizhuan.tutu.music.activity.MusicListActivity;
|
||||||
|
import com.yizhuan.xchat_android_core.DemoCache;
|
||||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||||
import com.yizhuan.xchat_android_core.music.db.bean.LocalMusicBean;
|
import com.yizhuan.xchat_android_core.music.db.bean.LocalMusicBean;
|
||||||
import com.yizhuan.xchat_android_core.music.event.CurrentMusicUpdateEvent;
|
import com.yizhuan.xchat_android_core.music.event.CurrentMusicUpdateEvent;
|
||||||
@@ -50,6 +51,7 @@ public class MusicPlayerView extends FrameLayout implements View.OnClickListener
|
|||||||
private ImageView musicListMore;
|
private ImageView musicListMore;
|
||||||
private ImageView musicPlayPause;
|
private ImageView musicPlayPause;
|
||||||
private ImageView nextBtn;
|
private ImageView nextBtn;
|
||||||
|
private ImageView musicPlayCycle;
|
||||||
private SeekBar volumeSeekBar;
|
private SeekBar volumeSeekBar;
|
||||||
private TextView musicName;
|
private TextView musicName;
|
||||||
private String imageBg;
|
private String imageBg;
|
||||||
@@ -71,26 +73,34 @@ public class MusicPlayerView extends FrameLayout implements View.OnClickListener
|
|||||||
private void init() {
|
private void init() {
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
LayoutInflater.from(getContext()).inflate(R.layout.layout_music_player_view, this, true);
|
LayoutInflater.from(getContext()).inflate(R.layout.layout_music_player_view, this, true);
|
||||||
musicFlagLayout = (FrameLayout) findViewById(R.id.music_flag_layout);
|
musicFlagLayout = findViewById(R.id.music_flag_layout);
|
||||||
musicFlagLayout.setOnClickListener(this);
|
musicFlagLayout.setOnClickListener(this);
|
||||||
musicFlag = (ImageView) findViewById(R.id.music_flag);
|
musicFlag = findViewById(R.id.music_flag);
|
||||||
musicBoxLayout = (RelativeLayout) findViewById(R.id.music_box_layout);
|
musicBoxLayout = findViewById(R.id.music_box_layout);
|
||||||
musicBoxLayout.setOnClickListener(this);
|
musicBoxLayout.setOnClickListener(this);
|
||||||
musicListMore = (ImageView) findViewById(R.id.music_list_more);
|
musicListMore = findViewById(R.id.music_list_more);
|
||||||
musicListMore.setOnClickListener(this);
|
musicListMore.setOnClickListener(this);
|
||||||
|
|
||||||
musicPlayPause = (ImageView) findViewById(R.id.music_play_pause);
|
musicPlayPause = findViewById(R.id.music_play_pause);
|
||||||
musicPlayPause.setOnClickListener(this);
|
musicPlayPause.setOnClickListener(this);
|
||||||
volumeSeekBar = (SeekBar) findViewById(R.id.voice_seek);
|
volumeSeekBar = findViewById(R.id.voice_seek);
|
||||||
volumeSeekBar.setMax(100);
|
volumeSeekBar.setMax(100);
|
||||||
volumeSeekBar.setProgress(PlayerModel.get().getCurrentVolume());
|
volumeSeekBar.setProgress(PlayerModel.get().getCurrentVolume());
|
||||||
volumeSeekBar.setOnSeekBarChangeListener(this);
|
volumeSeekBar.setOnSeekBarChangeListener(this);
|
||||||
musicName = (TextView) findViewById(R.id.music_name);
|
musicName = findViewById(R.id.music_name);
|
||||||
nextBtn = (ImageView) findViewById(R.id.music_play_next);
|
nextBtn = findViewById(R.id.music_play_next);
|
||||||
nextBtn.setOnClickListener(this);
|
nextBtn.setOnClickListener(this);
|
||||||
layoutMusicBgClick = findViewById(R.id.layout_music_bg_click);
|
layoutMusicBgClick = findViewById(R.id.layout_music_bg_click);
|
||||||
layoutMusicBgClick.setOnClickListener(this);
|
layoutMusicBgClick.setOnClickListener(this);
|
||||||
layoutMusicBgClick.setVisibility(INVISIBLE);
|
layoutMusicBgClick.setVisibility(INVISIBLE);
|
||||||
|
|
||||||
|
musicPlayCycle = findViewById(R.id.music_play_cycle);
|
||||||
|
musicPlayCycle.setOnClickListener(this);
|
||||||
|
if (DemoCache.readBgmSingleCycle()) {
|
||||||
|
musicPlayCycle.setImageResource(R.drawable.icon_music_single_cycle);
|
||||||
|
} else {
|
||||||
|
musicPlayCycle.setImageResource(R.drawable.icon_music_all_cycle);
|
||||||
|
}
|
||||||
updateView();
|
updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +120,7 @@ public class MusicPlayerView extends FrameLayout implements View.OnClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showFlagInAnim() {
|
private void showFlagInAnim() {
|
||||||
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(musicBoxLayout, "translationX", 0, -UIUtil.dip2px(getContext(), 287)).setDuration(150);
|
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(musicBoxLayout, "translationX", 0, -UIUtil.dip2px(getContext(), 317)).setDuration(150);
|
||||||
objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||||
objectAnimator.start();
|
objectAnimator.start();
|
||||||
|
|
||||||
@@ -143,7 +153,7 @@ public class MusicPlayerView extends FrameLayout implements View.OnClickListener
|
|||||||
objectAnimator.start();
|
objectAnimator.start();
|
||||||
|
|
||||||
|
|
||||||
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(musicBoxLayout, "translationX", -UIUtil.dip2px(getContext(), 287), 0).setDuration(150);
|
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(musicBoxLayout, "translationX", -UIUtil.dip2px(getContext(), 317), 0).setDuration(150);
|
||||||
objectAnimator1.setInterpolator(new AccelerateDecelerateInterpolator());
|
objectAnimator1.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||||
objectAnimator1.setStartDelay(150);
|
objectAnimator1.setStartDelay(150);
|
||||||
objectAnimator1.addListener(new AnimatorListenerAdapter() {
|
objectAnimator1.addListener(new AnimatorListenerAdapter() {
|
||||||
@@ -220,7 +230,16 @@ public class MusicPlayerView extends FrameLayout implements View.OnClickListener
|
|||||||
MusicListActivity.openLocalMusicList(getContext());
|
MusicListActivity.openLocalMusicList(getContext());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case R.id.music_play_cycle:
|
||||||
|
if (DemoCache.readBgmSingleCycle()) {
|
||||||
|
DemoCache.saveBgmSingleCycle(false);
|
||||||
|
musicPlayCycle.setImageResource(R.drawable.icon_music_all_cycle);
|
||||||
|
} else {
|
||||||
|
DemoCache.saveBgmSingleCycle(true);
|
||||||
|
musicPlayCycle.setImageResource(R.drawable.icon_music_single_cycle);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
app/src/module_music/res/drawable-xhdpi/icon_music_all_cycle.png
Normal file
BIN
app/src/module_music/res/drawable-xhdpi/icon_music_all_cycle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 872 B |
Binary file not shown.
After Width: | Height: | Size: 1021 B |
Binary file not shown.
After Width: | Height: | Size: 947 B |
Binary file not shown.
Before Width: | Height: | Size: 292 B |
@@ -37,11 +37,12 @@
|
|||||||
android:id="@+id/layout_music_bg_click"
|
android:id="@+id/layout_music_bg_click"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="gone">
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/music_box_layout"
|
android:id="@+id/music_box_layout"
|
||||||
android:layout_width="303dp"
|
android:layout_width="317dp"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:background="@drawable/shape_room_music_bg"
|
android:background="@drawable/shape_room_music_bg"
|
||||||
@@ -72,20 +73,21 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="22dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="22dp"
|
||||||
android:layout_marginStart="@dimen/dp_29"
|
android:layout_marginStart="@dimen/dp_25"
|
||||||
android:src="@drawable/icon_room_music_voice" />
|
android:src="@drawable/icon_room_music_voice" />
|
||||||
|
|
||||||
<SeekBar
|
<SeekBar
|
||||||
android:id="@+id/voice_seek"
|
android:id="@+id/voice_seek"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginEnd="@dimen/dp_5"
|
|
||||||
android:layout_weight="1.0"
|
android:layout_weight="1.0"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:maxHeight="3dip"
|
android:maxHeight="3dip"
|
||||||
android:minHeight="3dip"
|
android:minHeight="3dip"
|
||||||
|
android:layout_marginStart="-5dp"
|
||||||
|
android:layout_marginEnd="-5dp"
|
||||||
android:progressDrawable="@drawable/layer_list_room_music_bar"
|
android:progressDrawable="@drawable/layer_list_room_music_bar"
|
||||||
android:thumb="@drawable/icon_room_voice_point"
|
android:thumb="@drawable/icon_room_voice_point"
|
||||||
android:thumbOffset="0dp" />
|
android:thumbOffset="0dp" />
|
||||||
@@ -94,22 +96,30 @@
|
|||||||
android:id="@+id/music_play_pause"
|
android:id="@+id/music_play_pause"
|
||||||
android:layout_width="22dp"
|
android:layout_width="22dp"
|
||||||
android:layout_height="22dp"
|
android:layout_height="22dp"
|
||||||
android:layout_marginEnd="21dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:src="@drawable/icon_music_play" />
|
android:src="@drawable/icon_music_play" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/music_play_next"
|
android:id="@+id/music_play_next"
|
||||||
android:layout_width="22dp"
|
android:layout_width="22dp"
|
||||||
android:layout_height="22dp"
|
android:layout_height="22dp"
|
||||||
android:layout_marginEnd="21dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:src="@drawable/icon_music_next" />
|
android:src="@drawable/icon_music_next" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/music_play_cycle"
|
||||||
|
android:layout_width="22dp"
|
||||||
|
android:layout_height="22dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:src="@drawable/icon_music_all_cycle" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/music_list_more"
|
android:id="@+id/music_list_more"
|
||||||
android:layout_width="22dp"
|
android:layout_width="22dp"
|
||||||
android:layout_height="22dp"
|
android:layout_height="22dp"
|
||||||
android:layout_marginEnd="@dimen/dp_24"
|
android:layout_marginEnd="@dimen/dp_25"
|
||||||
android:src="@drawable/icon_music_list_more" />
|
android:src="@drawable/icon_music_list_more" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
@@ -252,7 +252,7 @@ public class RtcEngineManager extends BaseEngine {
|
|||||||
@Override
|
@Override
|
||||||
public int getAudioMixingCurrentPosition() {
|
public int getAudioMixingCurrentPosition() {
|
||||||
|
|
||||||
if (mRtcEngine != null) {
|
if (mRtcEngine == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int currentPosition = mRtcEngine.getAudioMixingCurrentPosition();
|
int currentPosition = mRtcEngine.getAudioMixingCurrentPosition();
|
||||||
|
@@ -644,7 +644,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAudioEffectFinished(int effectId, int code) {
|
public void onAudioEffectFinished(int effectId, int code) {
|
||||||
TRTCEngineAdapterListener.onAudioEffectFinished(effectId);
|
// TRTCEngineAdapterListener.onAudioEffectFinished(effectId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private TRTCEffectManager sTRTCEffectManager;
|
private TRTCEffectManager sTRTCEffectManager;
|
||||||
@@ -715,12 +715,10 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
|||||||
sTRTCEffectManager.setMusicObserver(new TXAudioEffectManager.TXMusicPlayObserver() {
|
sTRTCEffectManager.setMusicObserver(new TXAudioEffectManager.TXMusicPlayObserver() {
|
||||||
@Override
|
@Override
|
||||||
public void onStart(int id, int errCode) {
|
public void onStart(int id, int errCode) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayProgress(int id, long curPtsMS, long durationMS) {
|
public void onPlayProgress(int id, long curPtsMS, long durationMS) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1357,12 +1355,9 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
|||||||
}
|
}
|
||||||
curBgmcycle = 1;
|
curBgmcycle = 1;
|
||||||
totalBgmcycle = cycle;
|
totalBgmcycle = cycle;
|
||||||
trtcCloud.getAudioEffectManager().stopPlayMusic(mBGMId);
|
sTRTCEffectManager.stopEffect(mBGMId);
|
||||||
mBGMId++;
|
mBGMId++;
|
||||||
final TXAudioEffectManager.AudioMusicParam audioMusicParam = new TXAudioEffectManager.AudioMusicParam(mBGMId, filePath);
|
sTRTCEffectManager.playEffect(mBGMId,filePath,0,0,0,0,true);
|
||||||
audioMusicParam.publish = true; //上行
|
|
||||||
audioMusicParam.loopCount = cycle;
|
|
||||||
trtcCloud.getAudioEffectManager().startPlayMusic(audioMusicParam);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1376,7 +1371,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
|||||||
mBgmFilePath = "";
|
mBgmFilePath = "";
|
||||||
bgmisLoop = false;
|
bgmisLoop = false;
|
||||||
totalBgmcycle = 0;
|
totalBgmcycle = 0;
|
||||||
trtcCloud.getAudioEffectManager().stopPlayMusic(mBGMId);
|
sTRTCEffectManager.stopEffect(mBGMId);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1385,7 +1380,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
|||||||
if (!enableAudioFlag) {
|
if (!enableAudioFlag) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
trtcCloud.getAudioEffectManager().pausePlayMusic(mBGMId);
|
sTRTCEffectManager.pauseEffect(mBGMId);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1394,7 +1389,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
|||||||
if (!enableAudioFlag) {
|
if (!enableAudioFlag) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
trtcCloud.getAudioEffectManager().resumePlayMusic(mBGMId);
|
sTRTCEffectManager.resumeEffect(mBGMId);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1403,7 +1398,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
|||||||
if (!enableAudioFlag) {
|
if (!enableAudioFlag) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
trtcCloud.getAudioEffectManager().setAllMusicVolume(volume);
|
sTRTCEffectManager.setEffectsVolume(volume);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1412,7 +1407,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
|||||||
if (!enableAudioFlag) {
|
if (!enableAudioFlag) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
trtcCloud.getAudioEffectManager().setMusicPlayoutVolume(mBGMId, volume);
|
sTRTCEffectManager.setVolumeOfEffect(mBGMId,volume);
|
||||||
mMusicPlayoutVolume = volume;
|
mMusicPlayoutVolume = volume;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1422,7 +1417,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl {
|
|||||||
if (!enableAudioFlag) {
|
if (!enableAudioFlag) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
trtcCloud.getAudioEffectManager().setMusicPublishVolume(mBGMId, volume);
|
sTRTCEffectManager.setVolumeOfEffect(mBGMId,volume);
|
||||||
mMusicPublishVolume = volume;
|
mMusicPublishVolume = volume;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -230,14 +230,14 @@ public class TRtcEngineEventHandler implements IRTCEngineHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAudioMixingFinished() {//伴奏播放已结束回调
|
public void onAudioMixingFinished() {//伴奏播放已结束回调
|
||||||
IMNetEaseManager.get().getChatRoomEventObservable().onNext(
|
|
||||||
new RoomEvent().setEvent(RoomEvent.METHOD_ON_AUDIO_MIXING_FINISHED)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAudioEffectFinished(int soundId) {
|
public void onAudioEffectFinished(int soundId) {
|
||||||
|
IMNetEaseManager.get().getChatRoomEventObservable().onNext(
|
||||||
|
new RoomEvent().setEvent(RoomEvent.METHOD_ON_AUDIO_MIXING_FINISHED)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -208,7 +208,7 @@ public class TRtcEngineManager extends BaseEngine {
|
|||||||
result = mRtcEngine.resumeAudioMixing();
|
result = mRtcEngine.resumeAudioMixing();
|
||||||
} else {
|
} else {
|
||||||
LocalMusicBean current = PlayerModel.get().getCurrent();
|
LocalMusicBean current = PlayerModel.get().getCurrent();
|
||||||
startAudioMixing(current.getLocalUri(), false, 1);
|
startAudioMixing(current.getLocalUri(), false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
isMusicPlaying = true;
|
isMusicPlaying = true;
|
||||||
@@ -248,7 +248,7 @@ public class TRtcEngineManager extends BaseEngine {
|
|||||||
@Override
|
@Override
|
||||||
public int getAudioMixingCurrentPosition() {
|
public int getAudioMixingCurrentPosition() {
|
||||||
|
|
||||||
if (mRtcEngine != null) {
|
if (mRtcEngine == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int currentPosition = mRtcEngine.getAudioMixingCurrentPosition();
|
int currentPosition = mRtcEngine.getAudioMixingCurrentPosition();
|
||||||
|
@@ -61,6 +61,7 @@ public class DemoCache {
|
|||||||
private static final String KEY_FILTRATE_TYPE = "FilTrateType";
|
private static final String KEY_FILTRATE_TYPE = "FilTrateType";
|
||||||
private static final String KEY_RED_PACKAGE = "RedPackage";
|
private static final String KEY_RED_PACKAGE = "RedPackage";
|
||||||
private static final String KEY_AT_MSG_UUID = "AtMsgUuid";
|
private static final String KEY_AT_MSG_UUID = "AtMsgUuid";
|
||||||
|
private static final String KEY_BGM_SINGLE_CYCLE = "key_bgm_single_cycle";
|
||||||
/**
|
/**
|
||||||
* 保存网页域名
|
* 保存网页域名
|
||||||
*/
|
*/
|
||||||
@@ -338,5 +339,13 @@ public class DemoCache {
|
|||||||
return SettingsPref.instance(BasicConfig.INSTANCE.getAppContext()).getBoolean(KEY_BOX_MESSAGE + AuthModel.get().getCurrentUid(), true);
|
return SettingsPref.instance(BasicConfig.INSTANCE.getAppContext()).getBoolean(KEY_BOX_MESSAGE + AuthModel.get().getCurrentUid(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void saveBgmSingleCycle(boolean value) {
|
||||||
|
SettingsPref.instance(BasicConfig.INSTANCE.getAppContext()).putBoolean(KEY_BGM_SINGLE_CYCLE , value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean readBgmSingleCycle() {
|
||||||
|
return SettingsPref.instance(BasicConfig.INSTANCE.getAppContext()).getBoolean(KEY_BGM_SINGLE_CYCLE, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@ import android.os.Handler;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.yizhuan.xchat_android_core.DemoCache;
|
||||||
import com.yizhuan.xchat_android_core.base.BaseModel;
|
import com.yizhuan.xchat_android_core.base.BaseModel;
|
||||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||||
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||||
@@ -36,9 +37,9 @@ import io.realm.RealmResults;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class PlayerModel extends BaseModel implements IPlayerModel {
|
public class PlayerModel extends BaseModel implements IPlayerModel {
|
||||||
|
private final String AUDIO_SUFFIX_MP3 = ".mp3";
|
||||||
private boolean isRefresh;
|
private boolean isRefresh;
|
||||||
private List<LocalMusicBean> playerListMusicInfos;
|
private List<LocalMusicBean> playerListMusicInfos;
|
||||||
private final String AUDIO_SUFFIX_MP3 = ".mp3";
|
|
||||||
private LocalMusicBean current;
|
private LocalMusicBean current;
|
||||||
private List<LocalMusicBean> localMusicBeanList;
|
private List<LocalMusicBean> localMusicBeanList;
|
||||||
private long currentLocalId;
|
private long currentLocalId;
|
||||||
@@ -46,15 +47,7 @@ public class PlayerModel extends BaseModel implements IPlayerModel {
|
|||||||
private int volume;
|
private int volume;
|
||||||
private int recordingVolume;
|
private int recordingVolume;
|
||||||
private Disposable mDisposable;
|
private Disposable mDisposable;
|
||||||
|
private PlayHandler handler = new PlayHandler(this);
|
||||||
|
|
||||||
private static final class Helper {
|
|
||||||
public static final PlayerModel INSTANCE = new PlayerModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlayerModel get() {
|
|
||||||
return Helper.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private PlayerModel() {
|
private PlayerModel() {
|
||||||
playerListMusicInfos = new ArrayList<>();
|
playerListMusicInfos = new ArrayList<>();
|
||||||
@@ -85,6 +78,10 @@ public class PlayerModel extends BaseModel implements IPlayerModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PlayerModel get() {
|
||||||
|
return Helper.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRefresh() {
|
public boolean isRefresh() {
|
||||||
return isRefresh;
|
return isRefresh;
|
||||||
@@ -100,31 +97,6 @@ public class PlayerModel extends BaseModel implements IPlayerModel {
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayHandler handler = new PlayHandler(this);
|
|
||||||
|
|
||||||
static class PlayHandler extends Handler {
|
|
||||||
private WeakReference<PlayerModel> mWeakReference;
|
|
||||||
|
|
||||||
PlayHandler(PlayerModel playerCore) {
|
|
||||||
mWeakReference = new WeakReference<>(playerCore);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(Message msg) {
|
|
||||||
super.handleMessage(msg);
|
|
||||||
switch (msg.what) {
|
|
||||||
case 0:
|
|
||||||
PlayerModel playerCore = mWeakReference.get();
|
|
||||||
if (playerCore != null)
|
|
||||||
playerCore.playNext();
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LocalMusicBean> getPlayerListMusicInfos() {
|
public List<LocalMusicBean> getPlayerListMusicInfos() {
|
||||||
return playerListMusicInfos;
|
return playerListMusicInfos;
|
||||||
@@ -167,7 +139,6 @@ public class PlayerModel extends BaseModel implements IPlayerModel {
|
|||||||
refreshLocalMusic(null);
|
refreshLocalMusic(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMusicToPlayerList(LocalMusicBean localMusicInfo) {
|
public void addMusicToPlayerList(LocalMusicBean localMusicInfo) {
|
||||||
PlayerDbModel.get().addToPlayerList(localMusicInfo.getLocalId());
|
PlayerDbModel.get().addToPlayerList(localMusicInfo.getLocalId());
|
||||||
@@ -243,7 +214,7 @@ public class PlayerModel extends BaseModel implements IPlayerModel {
|
|||||||
}
|
}
|
||||||
AudioEngineManager.get().adjustAudioMixingVolume(volume);
|
AudioEngineManager.get().adjustAudioMixingVolume(volume);
|
||||||
AudioEngineManager.get().adjustRecordingSignalVolume(recordingVolume);
|
AudioEngineManager.get().adjustRecordingSignalVolume(recordingVolume);
|
||||||
int result = AudioEngineManager.get().startAudioMixing(localUri, false, 1);
|
int result = AudioEngineManager.get().startAudioMixing(localUri, false, 0);
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -276,7 +247,7 @@ public class PlayerModel extends BaseModel implements IPlayerModel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized int playNext() {
|
public synchronized int playNext() {
|
||||||
if(playerListMusicInfos==null || playerListMusicInfos.isEmpty()){
|
if (playerListMusicInfos == null || playerListMusicInfos.isEmpty()) {
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
@@ -350,4 +321,36 @@ public class PlayerModel extends BaseModel implements IPlayerModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class Helper {
|
||||||
|
public static final PlayerModel INSTANCE = new PlayerModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class PlayHandler extends Handler {
|
||||||
|
private WeakReference<PlayerModel> mWeakReference;
|
||||||
|
|
||||||
|
PlayHandler(PlayerModel playerCore) {
|
||||||
|
mWeakReference = new WeakReference<>(playerCore);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
super.handleMessage(msg);
|
||||||
|
switch (msg.what) {
|
||||||
|
case 0:
|
||||||
|
PlayerModel playerCore = mWeakReference.get();
|
||||||
|
if (playerCore != null) {
|
||||||
|
if (DemoCache.readBgmSingleCycle()) {
|
||||||
|
playerCore.play(playerCore.getCurrent());
|
||||||
|
} else {
|
||||||
|
playerCore.playNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user