Skip to content

Commit fda0978

Browse files
authored
Merge pull request #277 from athombv/fix/error-handling
Improve error handling
2 parents c7db6d3 + 69cc588 commit fda0978

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

ios/RCTVLCPlayer/RCTVLCPlayer.m

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,7 @@ - (void)mediaPlayerStateChanged:(NSNotification *)aNotification
237237
break;
238238
case VLCMediaPlayerStateError:
239239
NSLog(@"VLCMediaPlayerStateError %i", _player.numberOfAudioTracks);
240-
self.onVideoError(@{
241-
@"target": self.reactTag
242-
});
240+
// This callback doesn't have any data about the error, we need to rely on the error dialog
243241
[self _release];
244242
break;
245243
default:
@@ -431,20 +429,32 @@ - (void)setMuted:(BOOL)value
431429

432430
- (void)showErrorWithTitle:(NSString *)title message:(NSString *)message {
433431
NSLog(@"VLC Error - Title: %@, Message: %@", title, message);
434-
// Handle error dialog - can show custom UI or just log
432+
if (self.onVideoError) {
433+
self.onVideoError(@{
434+
@"target": self.reactTag,
435+
@"title": title ?: [NSNull null],
436+
@"message": message ?: [NSNull null]
437+
});
438+
}
435439
}
436440

437-
- (void)showLoginWithTitle:(NSString *)title
438-
message:(NSString *)message
439-
defaultUsername:(NSString *)username
440-
askingForStorage:(BOOL)askingForStorage
441+
- (void)showLoginWithTitle:(NSString *)title
442+
message:(NSString *)message
443+
defaultUsername:(NSString *)username
444+
askingForStorage:(BOOL)askingForStorage
441445
withReference:(NSValue *)reference {
442446
NSLog(@"VLC Login - Title: %@, Message: %@", title, message);
443-
// Handle login dialog - implement if needed for your use case
447+
if (self.onVideoError) {
448+
self.onVideoError(@{
449+
@"target": self.reactTag,
450+
@"title": title ?: [NSNull null],
451+
@"message": message ?: [NSNull null]
452+
});
453+
}
444454
}
445455

446-
- (void)showQuestionWithTitle:(NSString *)title
447-
message:(NSString *)message
456+
- (void)showQuestionWithTitle:(NSString *)title
457+
message:(NSString *)message
448458
type:(VLCDialogQuestionType)type
449459
cancelString:(NSString *)cancel
450460
action1String:(NSString *)action1

0 commit comments

Comments
 (0)