Skip to content

Commit

Permalink
Merge pull request #264 from AgoraIO-Usecase/feat/scene/ktv_android
Browse files Browse the repository at this point in the history
Feat/scene/ktv android
  • Loading branch information
zhangtao1104 authored Dec 15, 2022
2 parents d86ed4f + 0b45deb commit e6b5f31
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Android/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ ext {
gson : 'com.google.code.gson:gson:2.8.7',
autosize : 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1',

rtc : 'io.agora.rtc:agora-special-full:4.0.1.2',
rtc_special_voice : 'io.agora.rtc:agora-special-voice:4.0.1.2',
rtc_screen_sharing: 'io.agora.rtc:full-screen-sharing:4.0.1.2',
rtc : 'io.agora.rtc:agora-special-full:4.0.1.4',
rtc_special_voice : 'io.agora.rtc:agora-special-voice:4.0.1.4',
rtc_screen_sharing: 'io.agora.rtc:full-screen-sharing:4.0.1.4',
rtm : 'com.github.agorabuilder:rtm-sdk:1.4.10',
syncManager : 'com.github.AgoraIO-Community:SyncManager-Android:2.1.1',
lyricsView : 'com.github.AgoraIO-Community:LyricsView:1.0.20'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public void onBindViewHolder(@NonNull BindingViewHolder<KtvItemRoomSpeakerBindin
RoomSeatModel seatLocal = roomLivingViewModel.seatLocalLiveData.getValue();
if (seatLocal == null || seatLocal.getSeatIndex() < 0) {
roomLivingViewModel.haveSeat(position);
getBinding().cbMic.setChecked(false);
requestRecordPermission();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
import io.agora.scene.ktv.service.RemoveSongInputModel;
import io.agora.scene.ktv.service.RoomSeatModel;
import io.agora.scene.ktv.service.RoomSelSongModel;
import io.agora.scene.ktv.service.UpdateSingingScoreInputModel;
import io.agora.scene.ktv.widget.MusicSettingBean;
import io.agora.scene.ktv.widget.MusicSettingDialog;
import kotlin.Unit;
Expand Down Expand Up @@ -465,6 +464,7 @@ public Unit invoke(Exception e) {
mainChannelMediaOption.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
mRtcEngine.updateChannelMediaOptions(mainChannelMediaOption);
}
toggleMic(false);
} else {
// failure
Log.e(TAG, "RoomLivingViewModel.haveSeat() failed: " + e.getMessage());
Expand Down Expand Up @@ -1038,7 +1038,7 @@ public void onStreamMessage(int uid, int streamId, byte[] data) {
if (mPlayer == null) return;
long position = jsonMsg.getLong("position");
mPlayer.seek(position);
} else if (jsonMsg.getString("cmd").equals("SyncPitch")) {
} else if (jsonMsg.getString("cmd").equals("setVoicePitch")) {
// 伴唱收到原唱seek指令
if (mPlayer == null) return;
double pitch = jsonMsg.getDouble("pitch");
Expand All @@ -1062,7 +1062,6 @@ public void onAudioVolumeIndication(AudioVolumeInfo[] speakers, int totalVolume)
|| Objects.equals(songPlaying.getChorusNo(), UserManager.getInstance().getUser().userNo)) {
for (AudioVolumeInfo info : speakers) {
if (info.uid == 0 && playerMusicStatusLiveData.getValue() == PlayerMusicStatus.ON_PLAYING) {
ktvServiceProtocol.updateSingingScore(new UpdateSingingScoreInputModel(info.voicePitch));
if (mPlayer != null && mPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PLAYING) {
playerPitchLiveData.postValue(info.voicePitch);
pitch = info.voicePitch;
Expand Down Expand Up @@ -1906,7 +1905,7 @@ public void run() {

private void sendSyncPitch(double pitch) {
Map<String, Object> msg = new HashMap<>();
msg.put("cmd", "SyncPitch");
msg.put("cmd", "setVoicePitch");
msg.put("pitch", pitch);
JSONObject jsonMsg = new JSONObject(msg);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public void onChooseSongRefreshing(@NonNull SongDialog dialog, int index) {
LiveDataUtils.observerThenRemove(mLifecycleOwner,
mViewModel.getSongList(getSongType(index), mCurrPage),
list -> {
dialog.setChooseRefreshingResult(transSongModel(list));
if (dialog.isVisible()) {
dialog.setChooseRefreshingResult(transSongModel(list));
}
});
}

Expand All @@ -56,8 +58,10 @@ public void onChooseSongLoadMore(@NonNull SongDialog dialog, int index) {
LiveDataUtils.observerThenRemove(mLifecycleOwner,
mViewModel.getSongList(getSongType(index), mCurrPage),
list -> {
dialog.setChooseLoadMoreResult(transSongModel(list),
list.size() > 0);
if (dialog.isVisible()) {
dialog.setChooseLoadMoreResult(transSongModel(list),
list.size() > 0);
}
});
}

Expand All @@ -67,7 +71,9 @@ public void onChooseSongSearching(@NonNull SongDialog dialog, String condition)
LiveDataUtils.observerThenRemove(mLifecycleOwner,
mViewModel.searchSong(condition),
list -> {
dialog.setChooseSearchResult(transSongModel(list));
if (dialog.isVisible()) {
dialog.setChooseSearchResult(transSongModel(list));
}
});
}

Expand All @@ -78,7 +84,7 @@ public void onChooseSongChosen(@NonNull SongDialog dialog, @NonNull SongItem son
LiveDataUtils.observerThenRemove(mLifecycleOwner,
mViewModel.chooseSong(songModel, isChorus),
success -> {
if (success) {
if (success && dialog.isVisible()) {
dialog.setChooseSongItemStatus(songItem, true);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ class KTVSyncManagerServiceImp(
// ===================== 打分相关 =====================

override fun updateSingingScore(inputModel: UpdateSingingScoreInputModel) {
innerUpdateSingingScore(inputModel)
//innerUpdateSingingScore(inputModel)
}


Expand Down

0 comments on commit e6b5f31

Please sign in to comment.