yonge 3 rokov pred
rodič
commit
18db3ff61f

+ 19 - 7
audio-analysis/src/main/java/com/yonge/nettty/dto/UserChannelContext.java

@@ -32,7 +32,9 @@ public class UserChannelContext {
 	
 	private final static Logger LOGGER = LoggerFactory.getLogger(UserChannelContext.class);
 	
-	private int offsetMS = 300;
+	private int offsetMS = 100;
+	
+	private String platform;
 	
 	private Long recordId;
 	
@@ -67,7 +69,8 @@ public class UserChannelContext {
 	
 	private HardLevelEnum hardLevel = HardLevelEnum.ADVANCED;
 	
-	public void init(String heardLevel, int subjectId, int beatDuration) {
+	public void init(String platform, String heardLevel, int subjectId, int beatDuration) {
+		this.platform = platform;
 		this.subjectId = subjectId;
 		this.beatDuration = beatDuration;
 		this.beatByteLength = WaveformWriter.SAMPLE_RATE * WaveformWriter.BITS_PER_SAMPLE / 8 * beatDuration / 1000;
@@ -273,11 +276,20 @@ public class UserChannelContext {
 		
 		receivedTime += durationTime;
 		
-		/*if(receivedTime <= offsetMS){
-			return;
-		}*/
-		if(offsetMS == 0){
-			return;
+		switch (platform) {
+		case "ANDROID":
+			if (receivedTime <= offsetMS) {
+				return;
+			}
+			break;
+		case "IOS":
+			if(offsetMS == 0){
+				return;
+			}
+			break;
+
+		default:
+			break;
 		}
 		
 		playTime += durationTime;

+ 1 - 1
audio-analysis/src/main/java/com/yonge/netty/server/service/AudioCompareHandler.java

@@ -121,7 +121,7 @@ public class AudioCompareHandler implements MessageHandler {
 			}
 
 			channelContext.getSongMusicXmlMap().put(musicXmlBasicInfo.getExamSongId(), musicXmlBasicInfo);
-			channelContext.init(musicXmlBasicInfo.getHeardLevel(), musicXmlBasicInfo.getSubjectId(), musicXmlBasicInfo.getBeatLength());
+			channelContext.init(musicXmlBasicInfo.getPlatform(), musicXmlBasicInfo.getHeardLevel(), musicXmlBasicInfo.getSubjectId(), musicXmlBasicInfo.getBeatLength());
 
 			userChannelContextService.register(channel, channelContext);