11#import " PluginAPI.h"
22
3- @implementation NativeBridgePluginAPIDelegate
3+ @implementation PluginAPIDelegate
44
55+ (instancetype )sharedDelegate
66{
7- static NativeBridgePluginAPIDelegate *sharedInstance = nil ;
7+ static PluginAPIDelegate *sharedInstance = nil ;
88 static dispatch_once_t onceToken;
9- dispatch_once (&onceToken, ^{ sharedInstance = [[NativeBridgePluginAPIDelegate alloc ] init ]; });
9+ dispatch_once (&onceToken, ^{ sharedInstance = [[PluginAPIDelegate alloc ] init ]; });
1010 return sharedInstance;
1111}
1212
@@ -46,14 +46,14 @@ - (void)playerViewControllerDidStartPictureInPicture:(AVPlayerViewController *)p
4646- (void )playerViewController : (AVPlayerViewController *)playerViewController
4747 failedToStartPictureInPictureWithError : (NSError *)error
4848{
49- [Logger error: LOG_CATEGORY_NATIVEBRIDGE
49+ [Logger error: LOG_CATEGORY_PLUGINAPI
5050 format: @" Failed to start PiP: %@ " , error.localizedDescription];
5151}
5252
5353- (void )pictureInPictureController : (AVPictureInPictureController *)pictureInPictureController
5454 failedToStartPictureInPictureWithError : (NSError *)error
5555{
56- [Logger error: LOG_CATEGORY_NATIVEBRIDGE
56+ [Logger error: LOG_CATEGORY_PLUGINAPI
5757 format: @" PiP controller failed to start: %@ " , error.localizedDescription];
5858}
5959
@@ -92,7 +92,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath
9292 dispatch_async (dispatch_get_main_queue (), ^{
9393 @try
9494 {
95- [pip removeObserver: [NativeBridgePluginAPIDelegate sharedDelegate ]
95+ [pip removeObserver: [PluginAPIDelegate sharedDelegate ]
9696 forKeyPath: @" pictureInPicturePossible" ];
9797 }
9898 @catch (__unused NSException *e)
@@ -124,7 +124,7 @@ + (void)cleanupPiPResources
124124 {
125125 @try
126126 {
127- [currentPiPController removeObserver: [NativeBridgePluginAPIDelegate sharedDelegate ]
127+ [currentPiPController removeObserver: [PluginAPIDelegate sharedDelegate ]
128128 forKeyPath: @" pictureInPicturePossible"
129129 context: &kPiPObserverContext ];
130130 }
@@ -163,14 +163,14 @@ + (NSString *)playPiPVideo:(NSString *)videoURL
163163{
164164 if (!videoURL || [videoURL length ] == 0 )
165165 {
166- [Logger error: LOG_CATEGORY_NATIVEBRIDGE
166+ [Logger error: LOG_CATEGORY_PLUGINAPI
167167 format: @" Video URL is required for PiP video player" ];
168168 return nil ;
169169 }
170170
171171 if (![AVPictureInPictureController isPictureInPictureSupported ])
172172 {
173- [Logger error: LOG_CATEGORY_NATIVEBRIDGE format: @" PiP is not supported on this device" ];
173+ [Logger error: LOG_CATEGORY_PLUGINAPI format: @" PiP is not supported on this device" ];
174174 return nil ;
175175 }
176176
@@ -185,9 +185,9 @@ + (NSString *)playPiPVideo:(NSString *)videoURL
185185 {
186186 @try
187187 {
188- [currentPiPController removeObserver: [NativeBridgePluginAPIDelegate sharedDelegate ]
189- forKeyPath: @" pictureInPicturePossible"
190- context: &kPiPObserverContext ];
188+ [currentPiPController removeObserver: [PluginAPIDelegate sharedDelegate ]
189+ forKeyPath: @" pictureInPicturePossible"
190+ context: &kPiPObserverContext ];
191191 }
192192 @catch (__unused NSException *e)
193193 {
@@ -203,7 +203,7 @@ + (NSString *)playPiPVideo:(NSString *)videoURL
203203 NSURL *url = [NSURL URLWithString: videoURL];
204204 if (!url)
205205 {
206- [Logger error: LOG_CATEGORY_NATIVEBRIDGE format: @" Invalid video URL: %@ " , videoURL];
206+ [Logger error: LOG_CATEGORY_PLUGINAPI format: @" Invalid video URL: %@ " , videoURL];
207207 return ;
208208 }
209209
@@ -216,20 +216,20 @@ + (NSString *)playPiPVideo:(NSString *)videoURL
216216 error: &audioError];
217217 if (!ok || audioError)
218218 {
219- [Logger error: LOG_CATEGORY_NATIVEBRIDGE
219+ [Logger error: LOG_CATEGORY_PLUGINAPI
220220 format: @" Audio session category error: %@ " , audioError.localizedDescription];
221221 }
222222 audioError = nil ;
223223 ok = [session setActive: YES error: &audioError];
224224 if (!ok || audioError)
225225 {
226- [Logger error: LOG_CATEGORY_NATIVEBRIDGE
226+ [Logger error: LOG_CATEGORY_PLUGINAPI
227227 format: @" Audio session activate error: %@ " , audioError.localizedDescription];
228228 }
229229 }
230230 @catch (NSException *exception)
231231 {
232- [Logger error: LOG_CATEGORY_NATIVEBRIDGE
232+ [Logger error: LOG_CATEGORY_PLUGINAPI
233233 format: @" Audio session exception: %@ " , exception.reason];
234234 }
235235
@@ -244,7 +244,7 @@ + (NSString *)playPiPVideo:(NSString *)videoURL
244244 UIViewController *topViewController = [self topViewController ];
245245 if (!topViewController)
246246 {
247- [Logger error: LOG_CATEGORY_NATIVEBRIDGE
247+ [Logger error: LOG_CATEGORY_PLUGINAPI
248248 format: @" No top view controller found to host PiP layer" ];
249249 return ;
250250 }
@@ -272,7 +272,7 @@ + (NSString *)playPiPVideo:(NSString *)videoURL
272272 currentPiPController =
273273 [[AVPictureInPictureController alloc ] initWithPlayerLayer: currentPlayerLayer];
274274 }
275- currentPiPController.delegate = [NativeBridgePluginAPIDelegate sharedDelegate ];
275+ currentPiPController.delegate = [PluginAPIDelegate sharedDelegate ];
276276 currentPiPController.canStartPictureInPictureAutomaticallyFromInline = YES ;
277277
278278 [currentPlayer play ];
@@ -285,15 +285,15 @@ + (NSString *)playPiPVideo:(NSString *)videoURL
285285 {
286286 @try
287287 {
288- [currentPiPController addObserver: [NativeBridgePluginAPIDelegate sharedDelegate ]
288+ [currentPiPController addObserver: [PluginAPIDelegate sharedDelegate ]
289289 forKeyPath: @" pictureInPicturePossible"
290290 options: NSKeyValueObservingOptionNew
291291 context: &kPiPObserverContext ];
292292 sPiPObservationAdded = YES ;
293293 }
294294 @catch (NSException *exception)
295295 {
296- [Logger error: LOG_CATEGORY_NATIVEBRIDGE
296+ [Logger error: LOG_CATEGORY_PLUGINAPI
297297 format: @" Failed to add PiP KVO observer: %@ " , exception.reason];
298298 }
299299 }
@@ -371,12 +371,12 @@ + (NSString *)showNotification:(NSString *)title
371371 if (error)
372372 {
373373 [Logger
374- error: LOG_CATEGORY_NATIVEBRIDGE
374+ error: LOG_CATEGORY_PLUGINAPI
375375 format: @" Error scheduling notification: %@ " , error.localizedDescription];
376376 }
377377 else
378378 {
379- [Logger info: LOG_CATEGORY_NATIVEBRIDGE
379+ [Logger info: LOG_CATEGORY_PLUGINAPI
380380 format: @" Notification scheduled with id: %@ " , notificationId];
381381 }
382382 }];
0 commit comments