Skip to content

Commit c03e7cc

Browse files
author
chenjiulin
committed
fix #102
1 parent 00d5055 commit c03e7cc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ios/RTCSystemSetting.m

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ @interface RCTSystemSetting()
2828

2929
@implementation RCTSystemSetting {
3030
bool hasListeners;
31+
long skipSetVolumeCount;
3132
#ifdef BLUETOOTH
3233
CBCentralManager *cb;
3334
#endif
@@ -57,6 +58,7 @@ -(instancetype)init{
5758
}
5859

5960
-(void)initVolumeView{
61+
skipSetVolumeCount = 0;
6062
volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(-[UIScreen mainScreen].bounds.size.width, 0, 0, 0)];
6163
[self showVolumeUI:YES];
6264
for (UIView* view in volumeView.subviews) {
@@ -96,6 +98,7 @@ +(BOOL)requiresMainQueueSetup{
9698
}
9799

98100
RCT_EXPORT_METHOD(setVolume:(float)val config:(NSDictionary *)config){
101+
skipSetVolumeCount++;
99102
dispatch_sync(dispatch_get_main_queue(), ^{
100103
id showUI = [config objectForKey:@"showUI"];
101104
[self showVolumeUI:(showUI != nil && [showUI boolValue])];
@@ -216,10 +219,13 @@ -(void)stopObserving {
216219
}
217220

218221
-(void)volumeChanged:(NSNotification *)notification{
219-
if(hasListeners){
222+
if(skipSetVolumeCount == 0 && hasListeners){
220223
float volume = [[[notification userInfo] objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"] floatValue];
221224
[self sendEventWithName:@"EventVolume" body:@{@"value": [NSNumber numberWithFloat:volume]}];
222225
}
226+
if(skipSetVolumeCount > 0){
227+
skipSetVolumeCount--;
228+
}
223229
}
224230

225231
#ifdef BLUETOOTH

0 commit comments

Comments
 (0)