Kaynağa Gözat

fix. migrate ui api to main thread

matrixbirds 5 yıl önce
ebeveyn
işleme
68b4c36e6e
1 değiştirilmiş dosya ile 18 ekleme ve 12 silme
  1. 18
    12
      ios/RCTAgora/RCTAgora.m

+ 18
- 12
ios/RCTAgora/RCTAgora.m Dosyayı Görüntüle

@@ -158,23 +158,27 @@ RCT_EXPORT_METHOD(init:(NSDictionary *)options) {
158 158
   //enable dual stream
159 159
   if ([options objectForKey:@"dualStream"]) {
160 160
     [self.rtcEngine enableDualStreamMode:[options[@"dualStream"] boolValue]];
161
-     }
161
+  }
162
+  dispatch_sync(dispatch_get_main_queue(), ^{
163
+    [self.rtcEngine enableVideo];
164
+    [self.rtcEngine enableAudio];
165
+  });
162 166
   if ([options objectForKey:@"mode"]) {
163 167
     switch([options[@"mode"] integerValue]) {
164 168
        case AgoraAudioMode: {
165
-         [self.rtcEngine enableAudio];
166
-         [self.rtcEngine disableVideo];
169
+         [self.rtcEngine enableLocalAudio:true];
170
+         [self.rtcEngine enableLocalVideo:false];
167 171
          break;
168 172
        }
169 173
        case AgoraVideoMode: {
170
-         [self.rtcEngine enableVideo];
171
-         [self.rtcEngine disableAudio];
174
+         [self.rtcEngine enableLocalVideo:true];
175
+         [self.rtcEngine enableLocalAudio:false];
172 176
          break;
173 177
        }
174 178
     }
175 179
    } else {
176
-     [self.rtcEngine enableVideo];
177
-     [self.rtcEngine enableAudio];
180
+     [self.rtcEngine enableLocalVideo:true];
181
+     [self.rtcEngine enableLocalAudio:true];
178 182
    }
179 183
   
180 184
   if ([options objectForKey:@"beauty"]) {
@@ -1520,11 +1524,13 @@ RCT_EXPORT_METHOD(setCameraFocusPositionInPreview
1520 1524
                   :(NSDictionary *)options
1521 1525
                   resolve:(RCTPromiseResolveBlock)resolve
1522 1526
                   reject:(RCTPromiseRejectBlock)reject) {
1523
-  BOOL res = [self.rtcEngine setCameraFocusPositionInPreview:CGPointMake((CGFloat)[options[@"x"] floatValue], (CGFloat)[options[@"y"] floatValue])];
1524
-  resolve(@{
1525
-            @"success": @(YES),
1526
-            @"value": @(res)
1527
-            });
1527
+  dispatch_sync(dispatch_get_main_queue(), ^{
1528
+    BOOL res = [self.rtcEngine setCameraFocusPositionInPreview:CGPointMake((CGFloat)[options[@"x"] floatValue], (CGFloat)[options[@"y"] floatValue])];
1529
+    resolve(@{
1530
+              @"success": @(YES),
1531
+              @"value": @(res)
1532
+              });
1533
+  });
1528 1534
 }
1529 1535
 
1530 1536
 // setCameraExposurePosition