forked from davidohayon669/react-native-youtube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RCTYouTubeManager.m
73 lines (62 loc) · 1.83 KB
/
RCTYouTubeManager.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// MYNReactYouTubeViewManager.m
// Myntra
//
// Created by Param Aggarwal on 15/06/15.
// Copyright (c) 2015 Myntra Designs. All rights reserved.
//
#import "RCTYouTubeManager.h"
#import "RCTYouTube.h"
#import "RCTBridge.h"
#import "RCTUIManager.h"
#import "RCTWebView.h"
#import "UIView+React.h"
@implementation RCTYouTubeManager
RCT_EXPORT_MODULE();
@synthesize bridge = _bridge;
- (UIView *)view
{
return [[RCTYouTube alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
}
- (NSArray *)customDirectEventTypes
{
return @[
@"youtubeVideoReady",
@"youtubeVideoChangeState",
@"youtubeVideoChangeQuality",
@"youtubeVideoError",
@"youtubeProgress"
];
}
- (dispatch_queue_t)methodQueue
{
return _bridge.uiManager.methodQueue;
}
- (NSDictionary *)constantsToExport {
return @{
@"exportedProps": @{
@"videoId": @YES,
@"play": @YES,
@"hidden": @YES,
@"playsInline": @YES,
@"playerParams": @YES
}
};
}
RCT_EXPORT_VIEW_PROPERTY(videoId, NSString);
RCT_EXPORT_VIEW_PROPERTY(play, BOOL);
RCT_EXPORT_VIEW_PROPERTY(hidden, BOOL);
RCT_EXPORT_VIEW_PROPERTY(playsInline, BOOL);
RCT_EXPORT_VIEW_PROPERTY(playerParams, NSDictionary);
RCT_EXPORT_METHOD(seekTo:(nonnull NSNumber *)reactTag seconds:(nonnull NSNumber *)seconds)
{
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
RCTYouTube *youtube = viewRegistry[reactTag];
if ([youtube isKindOfClass:[RCTYouTube class]]) {
[youtube seekToSeconds:seconds.floatValue allowSeekAhead:@YES];
} else {
RCTLogError(@"Cannot seek: %@ (tag #%@) is not RCTYouTube", youtube, reactTag);
}
}];
}
@end