diff --git a/Headers/Public/VLCLibrary.h b/Headers/Public/VLCLibrary.h index 1247f2afba1bc3d560119deeb6c7bb59c2f4f367..1ea0429e4890905468e857e096c6840cf8365002 100644 --- a/Headers/Public/VLCLibrary.h +++ b/Headers/Public/VLCLibrary.h @@ -43,6 +43,16 @@ OBJC_VISIBLE @property (class, nonatomic, nullable) id<VLCEventsConfiguring> sharedEventsConfiguration; +/** + * A human-readable error message for the last LibVLC error in the calling + * thread. The resulting string is valid until another error occurs (at least + * until the next LibVLC call). + * + * @warning + * This will be NULL if there was no error. + */ +@property (class, nonatomic, copy, nullable) NSString *currentErrorMessage; + /** * Returns the library's shared instance * \return The library's shared instance diff --git a/Sources/Core/VLCLibrary.m b/Sources/Core/VLCLibrary.m index d1e5f91c51dbeab1e73df025fe78194c33202fef..86b6b06d393ac05fb30bbeab39668239d00f610a 100644 --- a/Sources/Core/VLCLibrary.m +++ b/Sources/Core/VLCLibrary.m @@ -104,6 +104,17 @@ static id<VLCEventsConfiguring> _sharedEventsConfiguration = nil; [self setSharedEventsConfiguration:[VLCEventsDefaultConfiguration new]]; } ++ (nullable NSString *)currentErrorMessage +{ + const char * __nullable errmsg = libvlc_errmsg(); + return errmsg ? @(errmsg) : nil; +} + ++ (void)setCurrentErrorMessage:(nullable NSString *)currentErrorMessage +{ + currentErrorMessage ? libvlc_printerr(currentErrorMessage.UTF8String) : libvlc_clearerr(); +} + + (VLCLibrary *)sharedLibrary { static dispatch_once_t onceToken;