Skip to content

Commit

Permalink
Dev/1.1.1 (#127)
Browse files Browse the repository at this point in the history
* [Android]perfect music player view and etc.

* [Android]perfect music player view.

* [Android]perfect music player view.

* fix: reject all invitations and applications that have already been used for a micseat

* docs: update change log

* [Android]fix conflicts between invitation and apply.

* doc: update change log.

---------

Co-authored-by: wushengtao <tamworth@163.com>
  • Loading branch information
xgfd3 and tamworth authored Mar 5, 2024
1 parent f1fd202 commit ee564a2
Show file tree
Hide file tree
Showing 17 changed files with 289 additions and 49 deletions.
2 changes: 1 addition & 1 deletion AUIKitCore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'AUIKitCore'
s.version = '1.1.0'
s.version = '1.1.1'
s.summary = 'A short description of AUIKit.'

# This description is used to generate tags and improve search results.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public interface IAUIJukeboxService extends IAUICommonService<IAUIJukeboxService
// 4 -> "抖音热歌"
// 5 -> "古风热歌"
// 6 -> "KTV必唱"
List<String> songCategories = Arrays.asList("热门新歌", "嗨歌推荐", "抖音热歌", "KTV必唱");
List<Integer> songCategoryIds = Arrays.asList(2, 3, 4, 6);
List<String> songCategories = Arrays.asList("嗨歌推荐", "抖音热歌", "热门新歌", "KTV必唱");
List<Integer> songCategoryIds = Arrays.asList(3, 4, 2, 6);
int songPageSize = 10;
int songPageStartIndex = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ enum class AUIInvitationCmd {
rejectInvit,
}

private val kSeatNoKey = "seatNo"
private val kStatusKey = "status"

private val kEditTimeKey = "editTime"

class AUIInvitationServiceImpl(
private val channelName: String,
private val rtmManager: AUIRtmManager
Expand Down Expand Up @@ -109,8 +114,8 @@ class AUIInvitationServiceImpl(
AUIInvitationCmd.sendInvit.name,
GsonTools.beanToMap(info),
listOf(
mapOf("userId" to userId, "status" to AUIInvitationInfo.AUIInvitationStatus.Waiting),
mapOf("userId" to userId, "status" to AUIInvitationInfo.AUIInvitationStatus.Accept),
mapOf("userId" to userId, kStatusKey to AUIInvitationInfo.AUIInvitationStatus.Waiting),
mapOf("userId" to userId, kStatusKey to AUIInvitationInfo.AUIInvitationStatus.Accept),
)
) {
callback?.onResult(
Expand All @@ -126,8 +131,8 @@ class AUIInvitationServiceImpl(
invitationCollection.mergeMetaData(
AUIInvitationCmd.acceptInvit.name,
mapOf(
"status" to AUIInvitationInfo.AUIInvitationStatus.Accept,
"editTime" to roomContext.ntpTime
kStatusKey to AUIInvitationInfo.AUIInvitationStatus.Accept,
kEditTimeKey to roomContext.ntpTime
),
listOf(mapOf("userId" to userId, "type" to AUIInvitationInfo.AUIInvitationType.Invite))
) {
Expand All @@ -144,8 +149,8 @@ class AUIInvitationServiceImpl(
invitationCollection.mergeMetaData(
AUIInvitationCmd.rejectInvit.name,
mapOf(
"status" to AUIInvitationInfo.AUIInvitationStatus.Reject,
"editTime" to roomContext.ntpTime
kStatusKey to AUIInvitationInfo.AUIInvitationStatus.Reject,
kEditTimeKey to roomContext.ntpTime
),
listOf(mapOf("userId" to userId, "type" to AUIInvitationInfo.AUIInvitationType.Invite))
) {
Expand All @@ -162,8 +167,8 @@ class AUIInvitationServiceImpl(
invitationCollection.mergeMetaData(
AUIInvitationCmd.cancelInvit.name,
mapOf(
"status" to AUIInvitationInfo.AUIInvitationStatus.Cancel,
"editTime" to roomContext.ntpTime
kStatusKey to AUIInvitationInfo.AUIInvitationStatus.Cancel,
kEditTimeKey to roomContext.ntpTime
),
listOf(
mapOf("userId" to userId, "type" to AUIInvitationInfo.AUIInvitationType.Invite)
Expand All @@ -188,8 +193,8 @@ class AUIInvitationServiceImpl(
AUIInvitationCmd.sendApply.name,
GsonTools.beanToMap(info),
listOf(
mapOf("userId" to info.userId, "status" to AUIInvitationStatus.Waiting),
mapOf("userId" to info.userId, "status" to AUIInvitationStatus.Accept)
mapOf("userId" to info.userId, kStatusKey to AUIInvitationStatus.Waiting),
mapOf("userId" to info.userId, kStatusKey to AUIInvitationStatus.Accept)
)
) {
callback.onResult(
Expand All @@ -209,8 +214,8 @@ class AUIInvitationServiceImpl(
invitationCollection.mergeMetaData(
AUIInvitationCmd.cancelApply.name,
mapOf(
"status" to AUIInvitationStatus.Cancel,
"editTime" to roomContext.ntpTime
kStatusKey to AUIInvitationStatus.Cancel,
kEditTimeKey to roomContext.ntpTime
),
listOf(
mapOf(
Expand All @@ -232,8 +237,8 @@ class AUIInvitationServiceImpl(
invitationCollection.mergeMetaData(
AUIInvitationCmd.acceptApply.name,
mapOf(
"status" to AUIInvitationStatus.Accept,
"editTime" to roomContext.ntpTime
kStatusKey to AUIInvitationStatus.Accept,
kEditTimeKey to roomContext.ntpTime
),
listOf(
mapOf("userId" to userId, "type" to AUIInvitationInfo.AUIInvitationType.Apply)
Expand All @@ -252,8 +257,8 @@ class AUIInvitationServiceImpl(
invitationCollection.mergeMetaData(
AUIInvitationCmd.rejectApply.name,
mapOf(
"status" to AUIInvitationInfo.AUIInvitationStatus.Reject,
"editTime" to roomContext.ntpTime
kStatusKey to AUIInvitationInfo.AUIInvitationStatus.Reject,
kEditTimeKey to roomContext.ntpTime
),
listOf(mapOf("userId" to userId, "type" to AUIInvitationInfo.AUIInvitationType.Apply))
) {
Expand All @@ -277,7 +282,7 @@ class AUIInvitationServiceImpl(
val tempItem = mutableMapOf<String, Any>()
tempItem.putAll(value)
val currentTime = roomContext.ntpTime
tempItem["editTime"] = currentTime
tempItem[kEditTimeKey] = currentTime
when (valueCmd) {
AUIInvitationCmd.sendInvit.name,
AUIInvitationCmd.sendApply.name -> tempItem["createTime"] = currentTime
Expand Down Expand Up @@ -311,7 +316,7 @@ class AUIInvitationServiceImpl(
return when (valueCmd) {
AUIInvitationCmd.acceptInvit.name -> {
val userId = oldValue["userId"] as? String ?: ""
val seatIndex = (oldValue["seatNo"] as? Long)?.toInt() ?: 0
val seatIndex = (oldValue[kSeatNoKey] as? Long)?.toInt() ?: 0
var error: AUIException? = null
observableHelper.notifyEventHandlers {
error = it.onInviteWillAccept(userId, seatIndex)
Expand All @@ -321,7 +326,7 @@ class AUIInvitationServiceImpl(

AUIInvitationCmd.acceptApply.name -> {
val userId = oldValue["userId"] as? String ?: ""
val seatIndex = (oldValue["seatNo"] as? Long)?.toInt() ?: 0
val seatIndex = (oldValue[kSeatNoKey] as? Long)?.toInt() ?: 0
var error: AUIException? = null
observableHelper.notifyEventHandlers {
error = it.onApplyWillAccept(userId, seatIndex)
Expand All @@ -345,10 +350,11 @@ class AUIInvitationServiceImpl(
) {
val list = value.getList() ?: return
val currentTime = roomContext.ntpTime
val filterList = list.filter { attr ->
val editTime = attr["editTime"] as? Long ?: 0
var filterList = rejectDuplicateAcceptedRequests(list) ?: list
filterList = filterList.filter { attr ->
val editTime = attr[kEditTimeKey] as? Long ?: 0
val invalidTs = attr["invalidTs"] as? Long ?: 0
val status = attr["status"] as? Int ?: 0
val status = attr[kStatusKey] as? Int ?: 0
if (status == AUIInvitationInfo.AUIInvitationStatus.Waiting) {
return@filter true
}
Expand Down Expand Up @@ -477,6 +483,28 @@ class AUIInvitationServiceImpl(
}
}

private fun rejectDuplicateAcceptedRequests(list: List<Map<String, Any>>): List<Map<String, Any>>? {
//获取accept的麦位数组
val acceptSeatNos = list.map { item ->
if (item[kStatusKey] == AUIInvitationStatus.Accept.toLong()) {
return@map item[kSeatNoKey] as? Long
}
return@map null
}

val updateList = mutableListOf<Map<String, Any>>()
list.forEach { i ->
val item = HashMap(i)
if(item[kStatusKey] == AUIInvitationStatus.Waiting.toLong() && acceptSeatNos.contains(item[kSeatNoKey])){
val currentTime = roomContext.ntpTime
item[kStatusKey] = AUIInvitationStatus.Reject
item[kEditTimeKey] = currentTime
}
updateList.add(item)
}
return updateList
}

private fun checkWaitingTimeout() {
if (roomContext.getArbiter(channelName)?.isArbiter() != true) {
return
Expand Down
2 changes: 1 addition & 1 deletion Android/auikit-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ dependencies {

// Ui Libraries
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.github.AgoraIO-Community:LyricsView:1.1.1-beta.8'
implementation 'com.github.AgoraIO-Community:LyricsView:1.1.1'
}

// Because the components are created only during the afterEvaluate phase, you must
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ interface ActionDelegate {
void onMusicPitch(int pitch);
void onAudioEffect(int effectId);
void onVoiceConversion(int voiceId);
void onSkipPrelude(long seekPosition);
void onSkipPostlude();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class AUIMusicPlayerView extends FrameLayout implements IMusicPlayerView
private MaterialButton mSwitchSongBtn;
private MaterialButton mActiveChooseSongBtn;
private MaterialButton mActiveOriginalBtn;
private View mActiveSkipPrelude;
private View mActiveSkipPostlude;
private MaterialButton mLeaveChorus;
private MaterialButton mControllerBtn;
private MaterialButton mPresetView;
Expand All @@ -85,6 +87,8 @@ public class AUIMusicPlayerView extends FrameLayout implements IMusicPlayerView

private MusicSettingInfo musicSettingInfo = new MusicSettingInfo();

private boolean isAudience = false;

public AUIMusicPlayerView(@NonNull Context context) {
super(context);
}
Expand Down Expand Up @@ -112,6 +116,8 @@ private void init(Context context) {
mSwitchSongBtn = mMusicPlayerActiveView.findViewById(R.id.ivChangeSong);
mActiveChooseSongBtn = mMusicPlayerActiveView.findViewById(R.id.ivChooseSong);
mActiveOriginalBtn = mMusicPlayerActiveView.findViewById(R.id.switchOriginal);
mActiveSkipPrelude = mMusicPlayerActiveView.findViewById(R.id.llSkipPrelude);
mActiveSkipPostlude = mMusicPlayerActiveView.findViewById(R.id.llSkipPostlude);
mKaraokeView = new KaraokeView(mLrcView, mScoringView);
mMusicControllerGroup = mMusicPlayerActiveView.findViewById(R.id.rlMusicControlMenu);
mJoinChorusView = mMusicPlayerActiveView.findViewById(R.id.btnJoinChorus);
Expand All @@ -123,7 +129,7 @@ private void init(Context context) {
mPresetView = findViewById(R.id.ivMusicPreset);
mLineScore = findViewById(R.id.tvLineScore);
mPrepareView = findViewById(R.id.il_musicplayer_prepare_view);
mPreparePrecent = mPrepareView.findViewById(R.id.ivPrepareView);
mPreparePrecent = mPrepareView.findViewById(R.id.tvProgress);
initListener();
}

Expand Down Expand Up @@ -195,6 +201,27 @@ public void onLineFinished(KaraokeView view, LyricsLineModel line, int score, in
mPresetView.setOnClickListener(v -> {
showPresetDialog();
});

// 跳过前奏
mActiveSkipPrelude.findViewById(R.id.ivSkipPreludeSkip).setOnClickListener(v -> {
LyricsModel lyricsData = mKaraokeView.getLyricsData();
if (lyricsData != null) {
long seekPosition = lyricsData.startOfVerse - 2000;
mActionDelegate.onSkipPrelude(seekPosition);
}
mActiveSkipPrelude.setVisibility(View.INVISIBLE);
});
mActiveSkipPrelude.findViewById(R.id.ivSkipPreludeCancel).setOnClickListener(v -> {
mActiveSkipPrelude.setVisibility(View.INVISIBLE);
});

// 跳过尾奏
mActiveSkipPostlude.findViewById(R.id.ivSkipPostludeSkip).setOnClickListener(v -> {
mActionDelegate.onSkipPostlude();
});
mActiveSkipPostlude.findViewById(R.id.ivSkipPostludeCancel).setOnClickListener(v -> {
mActiveSkipPostlude.setVisibility(View.INVISIBLE);
});
}

@Override
Expand Down Expand Up @@ -271,6 +298,18 @@ public void onAcc() {

// 设置进程
public void setProgress(Long progress) {
if (!isAudience) {
if (progress >= mKaraokeView.getLyricsData().startOfVerse - 2000) {
mActiveSkipPrelude.setVisibility(View.INVISIBLE);
}

if (progress >= mKaraokeView.getLyricsData().duration) {
mActiveSkipPostlude.setVisibility(View.VISIBLE);
} else {
mActiveSkipPostlude.setVisibility(View.INVISIBLE);
}
}

mKaraokeView.setProgress(progress);
}

Expand Down Expand Up @@ -332,11 +371,11 @@ public void onMusicPrepare(String songName, boolean isAudience, boolean isRoomOw
mPreparePrecent.setText("0%");
mActiveOriginalBtn.setActivated(false);

this.isAudience = isAudience;
if (isAudience) {
mMusicControllerGroup.setVisibility(View.GONE);
mJoinChorusView.setVisibility(View.VISIBLE);
mJoinChorusLoadingView.setVisibility(View.INVISIBLE);

if (isRoomOwner) {
// 房主允许切歌
mSwitchSongBtn.setVisibility(View.VISIBLE);
Expand All @@ -347,6 +386,8 @@ public void onMusicPrepare(String songName, boolean isAudience, boolean isRoomOw
mJoinChorusView.setVisibility(View.INVISIBLE);
mJoinChorusLoadingView.setVisibility(View.INVISIBLE);
}
mActiveSkipPrelude.setVisibility(View.INVISIBLE);
mActiveSkipPostlude.setVisibility(View.INVISIBLE);
});
}

Expand All @@ -355,6 +396,9 @@ public void onMusicPlaying() {
mainHandler.post(() -> {
mGradeView.setScore(0, 0, 0);
mPrepareView.setVisibility(View.INVISIBLE);
if (!isAudience) {
mActiveSkipPrelude.setVisibility(View.VISIBLE);
}
});
}

Expand All @@ -375,6 +419,8 @@ public void onJoinChorus(boolean isRoomOwner) {
}
mLeaveChorus.setVisibility(View.VISIBLE);
mMusicStartBtn.setVisibility(View.GONE);
mActiveSkipPrelude.setVisibility(View.INVISIBLE);
mActiveSkipPostlude.setVisibility(View.INVISIBLE);
});
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="#EE4130C7"/>

<corners android:radius="999dp"/>

</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="360dp" />
<stroke
android:width="1.16px"
android:color="#33FFFFFF" />

<solid android:color="#DF000000" />
</shape>
Loading

0 comments on commit ee564a2

Please sign in to comment.