diff --git a/RCTYouTubeManager.m b/RCTYouTubeManager.m index cd4a5dfe..73377b3d 100644 --- a/RCTYouTubeManager.m +++ b/RCTYouTubeManager.m @@ -46,6 +46,30 @@ - (dispatch_queue_t)methodQueue { }]; } +RCT_EXPORT_METHOD(mute:(nonnull NSNumber *)reactTag) +{ + [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) { + RCTYouTube *youtube = (RCTYouTube*)viewRegistry[reactTag]; + if ([youtube isKindOfClass:[RCTYouTube class]]) { + [youtube mute]; + } else { + RCTLogError(@"Cannot mute: %@ (tag #%@) is not RCTYouTube", youtube, reactTag); + } + }]; +} + +RCT_EXPORT_METHOD(unMute:(nonnull NSNumber *)reactTag) +{ + [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) { + RCTYouTube *youtube = (RCTYouTube*)viewRegistry[reactTag]; + if ([youtube isKindOfClass:[RCTYouTube class]]) { + [youtube unMute]; + } else { + RCTLogError(@"Cannot unMute: %@ (tag #%@) is not RCTYouTube", youtube, reactTag); + } + }]; +} + RCT_EXPORT_METHOD(nextVideo:(nonnull NSNumber *)reactTag) { [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) { diff --git a/README.md b/README.md index 55a8e288..6f70f6a2 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,8 @@ The iOS implementation of this player uses the official YouTube iFrame under the * `currentTime()`: Returns a Promise that results with the `currentTime` of the played video (in seconds) or errors with an errorMessage string. Should be used as an alternative for Android to `onProgress` event on iOS. * `duration()` *(Android)*: Returns a Promise that results with the `duration` of the played video (in seconds) or errors with an errorMessage string. Should be used as an alternative for Android to `onProgress` event on iOS. * `reloadIframe()` *(iOS)*: Specific props (`fullscreen`, `modestbranding`, `showinfo`, `rel`, `controls`, `origin`) can only be set at mounting and initial loading of the underlying WebView that holds the YouTube iFrame (Those are `