* 开始演唱。在歌词/歌曲下载完成,收到开始演唱广播后执行。
* @param filePath 歌曲的文件路径
public void startStartSing(String filePath) {
IMediaPlayer mediaPlayer = mRTCVideo.getMediaPlayer(0);
MediaPlayerConfig playerConfig = new MediaPlayerConfig(AUDIO_MIXING_TYPE_PLAYOUT_AND_PUBLISH, 1);
mediaPlayer.open(filePath, playerConfig);
mediaPlayer.setProgressInterval(500);
* @param progress 歌曲播放进度,单位为毫秒
public void onMediaPlayerPlayingProgress(int playerId, long progress) {
syncLocalLyricsProgress(progress);
String progressStr = String.valueOf(progress);
StreamSycnInfoConfig streamSycnInfoConfig = new StreamSycnInfoConfig(
StreamIndex.STREAM_INDEX_MAIN,
StreamSycnInfoConfig.SyncInfoStreamType.SYNC_INFO_STREAM_TYPE_AUDIO
mRTCVideo.sendStreamSyncInfo(progressStr.getBytes(StandardCharsets.UTF_8), streamSycnInfoConfig);
* @param streamKey 远端流信息
* @param streamType 媒体流类型
public void onStreamSyncInfoReceived(RemoteStreamKey streamKey, StreamSycnInfoConfig.SyncInfoStreamType streamType, ByteBuffer data) {
Charset charset = StandardCharsets.UTF_8;
CharsetDecoder decoder = charset.newDecoder();
CharBuffer charBuffer = null;
charBuffer = decoder.decode(data);
} catch (CharacterCodingException e) {
String progressStr = charBuffer != null ? charBuffer.toString() : null;
long progress = Long.parseLong(progressStr);
syncLocalLyricsProgress(progress);