2
2
#import " BrightcovePlayerUtil.h"
3
3
#import " BrightcovePlayerOfflineVideoManager.h"
4
4
5
- static BOOL sharedOfflineVideoManagerInitialized = false ;
6
-
7
5
@implementation BrightcovePlayerUtil
8
6
9
7
RCT_EXPORT_MODULE ();
@@ -53,7 +51,7 @@ - (dispatch_queue_t)methodQueue {
53
51
}
54
52
55
53
RCT_EXPORT_METHOD (getOfflineVideoStatuses:(NSString *)accountId policyKey:(NSString *)policyKey resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
56
- resolve ([self collecteOfflineVideoStatuses ]);
54
+ resolve ([self collectOfflineVideoStatuses ]);
57
55
}
58
56
59
57
RCT_EXPORT_METHOD (deleteOfflineVideo:(NSString *)accountId policyKey:(NSString *)policyKey videoToken:(NSString *)videoToken resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
@@ -62,7 +60,29 @@ - (dispatch_queue_t)methodQueue {
62
60
resolve (nil );
63
61
}
64
62
65
- - (NSArray *)collecteOfflineVideoStatuses {
63
+ RCT_EXPORT_METHOD (getPlaylistWithPlaylistId:(NSString *)playlistId accountId:(NSString *)accountId policyKey:(NSString *)policyKey resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
64
+ BCOVPlaybackService* playbackService = [[BCOVPlaybackService alloc ] initWithAccountId: accountId policyKey: policyKey];
65
+ [playbackService findPlaylistWithPlaylistID: playlistId parameters: nil completion: ^(BCOVPlaylist *playlist, NSDictionary *jsonResponse, NSError *error) {
66
+ if (error) {
67
+ reject (@" error" , error.description , error);
68
+ return ;
69
+ }
70
+ resolve ([self collectPlaylist: playlist]);
71
+ }];
72
+ }
73
+
74
+ RCT_EXPORT_METHOD (getPlaylistWithReferenceId:(NSString *)referenceId accountId:(NSString *)accountId policyKey:(NSString *)policyKey resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
75
+ BCOVPlaybackService* playbackService = [[BCOVPlaybackService alloc ] initWithAccountId: accountId policyKey: policyKey];
76
+ [playbackService findPlaylistWithReferenceID: referenceId parameters: nil completion: ^(BCOVPlaylist *playlist, NSDictionary *jsonResponse, NSError *error) {
77
+ if (error) {
78
+ reject (@" error" , error.description , error);
79
+ return ;
80
+ }
81
+ resolve ([self collectPlaylist: playlist]);
82
+ }];
83
+ }
84
+
85
+ - (NSArray *)collectOfflineVideoStatuses {
66
86
NSArray * statuses = [[BrightcovePlayerOfflineVideoManager sharedManager ] offlineVideoStatus ];
67
87
NSMutableArray *results = [[NSMutableArray alloc ] init ];
68
88
for (BCOVOfflineVideoStatus *status in statuses) {
@@ -75,6 +95,30 @@ - (NSArray *)collecteOfflineVideoStatuses {
75
95
return results;
76
96
}
77
97
98
+ - (NSArray *)collectPlaylist : (BCOVPlaylist *)playlist {
99
+ NSMutableArray *videos = [[NSMutableArray alloc ] init ];
100
+ for (BCOVVideo *video in playlist.videos ) {
101
+ NSString *name = video.properties [kBCOVVideoPropertyKeyName ];
102
+ if (!name) {
103
+ name = @" " ;
104
+ }
105
+ NSString *description = video.properties [kBCOVVideoPropertyKeyDescription ];
106
+ if (!description) {
107
+ description = @" " ;
108
+ }
109
+ [videos addObject:
110
+ @{
111
+ @" accountId" : video.properties [kBCOVVideoPropertyKeyAccountId ],
112
+ @" videoId" : video.properties [kBCOVVideoPropertyKeyId ],
113
+ @" referenceId" : video.properties [kBCOVVideoPropertyKeyReferenceId ],
114
+ @" name" : name,
115
+ @" description" : description,
116
+ @" duration" : video.properties [kBCOVVideoPropertyKeyDuration ]
117
+ }];
118
+ }
119
+ return videos;
120
+ }
121
+
78
122
- (NSDictionary *)generateDownloadParameterWithBitRate : (NSNumber *)bitRate {
79
123
return
80
124
@{
0 commit comments