Steven 1 рік тому
батько
коміт
25ba18b04a

BIN
KulexiuForTeacher/KulexiuForTeacher/Assets.xcassets/CustomAlert/premissionAlert_top.imageset/premissionAlert_top@2x.png


BIN
KulexiuForTeacher/KulexiuForTeacher/Assets.xcassets/CustomAlert/premissionAlert_top.imageset/premissionAlert_top@3x.png


+ 17 - 8
KulexiuForTeacher/KulexiuForTeacher/Common/Base/KSAccompanyWebViewController.m

@@ -119,6 +119,8 @@
 
 @property (nonatomic, assign) BOOL muteAccompany; // 是否静音
 
+@property (nonatomic, assign) NSInteger musicStartTime;  // 开始播放的时间
+
 @end
 
 @implementation KSAccompanyWebViewController
@@ -512,13 +514,17 @@
                 }
             }
             else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"endEvaluating"]) {// 停止评测
-                self.evaluatParm = nil;
-                [self stopRecordService];
-                [self postMessage:parm];
-                [self sendEndMessage];
-                [self stopMp3Player]; // 停止播放
+                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                    self.musicStartTime = 0;
+                    self.evaluatParm = nil;
+                    [self stopRecordService];
+                    [self postMessage:parm];
+                    [self sendEndMessage];
+                    [self stopMp3Player]; // 停止播放
+                });
             }
             else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"cancelEvaluating"]) { // 取消评测
+                self.musicStartTime = 0;
                 self.evaluatParm = nil;
                 [self stopRecordService];
                 [self postMessage:parm];
@@ -526,6 +532,7 @@
             }
             else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"startRecording"]) { //  开始录制
                 NSDictionary *content = [parm ks_dictionaryValueForKey:@"content"];
+                self.musicStartTime = [content ks_integerValueForKey:@"firstNoteTime"];
                 if ([[content allKeys] containsObject:@"accompanimentState"]) {
                     BOOL mute = [content ks_boolValueForKey:@"accompanimentState"] == NO;
                     self.muteAccompany = mute;
@@ -1265,6 +1272,7 @@
         dispatch_main_sync_safe(^{
             self.musicPlayer.isMute = self.muteAccompany;
             [self.musicPlayer startPlay];
+            [self.musicPlayer seekToTimePlay:self.musicStartTime];
         });
     }
 }
@@ -1663,10 +1671,11 @@
         }
     }
     
-    if (playTime >= 300 && playTime < 310 && player == self.musicPlayer) {
+    if (playTime >= self.musicStartTime + 300 && playTime < self.musicStartTime + 310 && player == self.musicPlayer) {
         if (self.recordStartTime > 0) {
-            NSLog(@" --- music player start play time %f", currentInterval*1000 - playTime);
-            self.playerStartTime = currentInterval*1000 - playTime;
+            NSInteger newPlayTime = playTime - self.musicStartTime; // 选段
+            NSLog(@" --- music player start play time %f", currentInterval*1000 - newPlayTime);
+            self.playerStartTime = currentInterval*1000 - newPlayTime;
             self.offsetTime = self.playerStartTime - self.recordStartTime;
             NSLog(@"--------- music play offset time -- %zd", self.offsetTime);
             [self sendOffsetTimeToService];

+ 4 - 4
KulexiuForTeacher/KulexiuForTeacher/Common/Tools/MicAlert/KSPremissionAlert.xib

@@ -87,7 +87,7 @@
                     </userDefinedRuntimeAttributes>
                 </view>
                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="premissionAlert_top" translatesAutoresizingMaskIntoConstraints="NO" id="vbf-dN-F4O">
-                    <rect key="frame" x="67" y="287.5" width="280" height="153"/>
+                    <rect key="frame" x="75" y="287.5" width="264" height="153"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="153" id="xm2-rZ-dtN"/>
                     </constraints>
@@ -95,8 +95,8 @@
             </subviews>
             <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
             <constraints>
-                <constraint firstItem="Nar-aj-LSw" firstAttribute="leading" secondItem="vbf-dN-F4O" secondAttribute="leading" constant="8" id="A6w-rp-gOf"/>
-                <constraint firstItem="Nar-aj-LSw" firstAttribute="trailing" secondItem="vbf-dN-F4O" secondAttribute="trailing" constant="-8" id="S5Y-ZD-ewO"/>
+                <constraint firstItem="Nar-aj-LSw" firstAttribute="leading" secondItem="vbf-dN-F4O" secondAttribute="leading" id="A6w-rp-gOf"/>
+                <constraint firstItem="Nar-aj-LSw" firstAttribute="trailing" secondItem="vbf-dN-F4O" secondAttribute="trailing" id="S5Y-ZD-ewO"/>
                 <constraint firstItem="Nar-aj-LSw" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="YCi-8R-dsx"/>
                 <constraint firstItem="Nar-aj-LSw" firstAttribute="top" secondItem="vbf-dN-F4O" secondAttribute="top" constant="35" id="ZMq-4D-8Ji"/>
                 <constraint firstItem="Nar-aj-LSw" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="kE3-af-hWl"/>
@@ -112,7 +112,7 @@
     <resources>
         <image name="alert_button_cancle" width="117" height="37"/>
         <image name="alert_button_open" width="117" height="37"/>
-        <image name="premissionAlert_top" width="280" height="153"/>
+        <image name="premissionAlert_top" width="264" height="153"/>
         <systemColor name="systemBackgroundColor">
             <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
         </systemColor>

+ 5 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Login/Model/UserInfoManager.m

@@ -106,6 +106,11 @@
 }
 
 - (void)checkTokenEnableCallback:(void(^)(BOOL enable))checkCallback {
+    NSString *token = UserDefault(TokenKey);
+    if ([NSString isEmptyString:token]) {
+        checkCallback(NO);
+        return;
+    }
     [KSNetworkingManager checkTokenRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
         if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
             checkCallback(YES);