Main Singer | Chorus | Audience |
NTP time calibration Enable black frame insertion Send SEI messages Local lyrics synchronization Update lyrics control | NTP time calibration Local lyrics synchronization Update lyrics control | NTP time calibration Receive SEI messages Update lyrics control |
// In pure audio mode, the main instance (vocal instance)// needs to enable black frame padding to carry SEI messages.NSDictionary *jsonDic = @{@"api": @"enableBlackStream",@"params":@{@"enable": @(1)}};NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDic options:NSJSONWritingPrettyPrinted error:nil];NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];[trtcCloud callExperimentalAPI:jsonString];
enableBlackStream
needs to be called after entering the room;enable
parameter is Boolean, and on iOS it is Integer;startRemoteView(userId, null)
after receiving onUserVideoAvailable(userId, true)
.TXAudioMusicProgressBlock progressBlock = ^(NSInteger progressMs, NSInteger durationMs) {// current ntp timeNSInteger ntpTime = [TXLiveBase getNetworkTimestamp];// Notify the song progress, users will scroll the lyrics here.NSDictionary *progressMsg = @{@"bgmProgressTime":@(progressMs),@"ntpTime":@(ntpTime),@"musicId": @(musicId),@"duration": @(durationMs),};NSData *jsonData = [NSJSONSerialization dataWithJSONObject:progressMsg options:NSJSONWritingPrettyPrinted error:nil];NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];[trtcCloud sendSEIMsg:[jsonString dataUsingEncoding:NSUTF8StringEncoding] repeatCount:1];};
// local lyrics synchronizationTXAudioMusicProgressBlock progressBlock = ^(NSInteger progressMs, NSInteger durationMs) {...// TODO Update the logic of the lyrics control.// Determine whether it is necessary to seek the lyrics control// based on the latest progress and the error of the local lyrics progress....};// remote lyrics synchronization.- (void)onRecvSEIMsg:(NSString *)userId message:(NSData *)message {NSError *err = nil;NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:message options:NSJSONReadingMutableContainers error:&err];if (err || ![dic isKindOfClass:[NSDictionary class]]) {// Parsing error.return;}NSInteger bgmProgressTime = [[dic objectForKey:@"bgmProgressTime"] integerValue];NSInteger ntpTime = [[dic objectForKey:@"ntpTime"] integerValue];int32_t musicId = [[dic objectForKey:@"musicId"] intValue];NSInteger duration = [[dic objectForKey:@"duration"] integerValue];...// TODO Update the logic of the lyrics control.// Determine whether it is necessary to seek the lyrics control// based on the received latest progress and the error of the local lyrics progress....}
Was this page helpful?