Lead Singer | Chorus | Audience |
NTP time calibration Turn on black frame compensation Send SEI message Local lyrics synchronization Update lyrics widget | NTP time calibration Local lyrics synchronization Update lyrics widget | NTP time calibration Receive SEI message Update lyrics widget |
// In pure audio mode, the main instance (vocal instance) needs to turn on black frame compensation to carry the SEI message.mTRTCCloud.callExperimentalAPI("{\\"api\\":\\"enableBlackStream\\",\\"params\\": {\\"enable\\":true}}");
mAudioEffectManager.setMusicObserver(mCurPlayMusicId, new TXAudioEffectManager.TXMusicPlayObserver() {@Overridepublic void onPlayProgress(int id, long curPtsMS, long durationMS) {JSONObject jsonObject = new JSONObject();// Current NTP timelong ntpTime = TXLiveBase.getNetworkTimestamp();jsonObject.put("bgmProgressTime", curTime);jsonObject.put("ntpTime", ntpTime);jsonObject.put("musicId", musicId);jsonObject.put("duration", duration);jsonObject.toString().getBytes();mTRTCCloud.sendSEIMsg(jsonObject.toString().getBytes(), 1);}}
// Local lyrics synchronizationmAudioEffectManager.setMusicObserver(mCurPlayMusicId, new TXAudioEffectManager.TXMusicPlayObserver() {@Overridepublic void onPlayProgress(int id, long curPtsMS, long durationMS) {...// TODO Update lyrics widget logic:// Determine whether to seek the lyrics widget based on the latest progress and local lyrics progress error...}}// Remote lyrics synchronization@Overridepublic void onRecvSEIMsg(String userId, byte[] data) {String result = new String(data);JSONObject jsonObject = new JSONObject(result);long bgmProgressTime = jsonObject.getLong("bgmProgressTime");long ntpTime = jsonObject.getLong("ntpTime");String musicId = jsonObject.getString("musicId");long duration = jsonObject.getLong("duration");...// TODO Update lyrics widget logic:// If you reuse the TUIKaraoke component's lyrics widget,//please refer to the code logic of the TUIKaraoke LyricsView section to synchronize the lyrics widget progress....}
Was this page helpful?