robovm
robovm copied to clipboard
AVAsset.loadValuesAsynchronouslyForKeys wrong method signature?
Issue details: AVAsset.loadValuesAsynchronouslyForKeys is declared like this in Objective-C:
- (void)loadValuesAsynchronouslyForKeys:(NSArray<NSString *> *)keys
completionHandler:(void (^)(void))handler;
But in RoboVM, it asks for List<AVMetadataKey>
instead of List<NSString>
.
I need to pass strings such as this:
[test loadValuesAsynchronouslyForKeys:@[@"playable",@"tracks"] completionHandler:^{
// Now tracks is available
NSLog(@" total tracks %@", test.tracks);
}];
Help!
Versions: RoboVM 2.3.9-SNAPSHOT
sadly apple doesn't expose @"playable",@"tracks" in way of global values (as it does for other keys) and API of AVAsset.loadValuesAsynchronouslyForKeys is build with sugared GlobalValueEnumeration. As there is no global values -- no global enum entry can be make for them. it might be done with workaround by changing type binding for this selector. Try snippet bellow (have not tested myself):
public static void test() {
AVAsset asset = new AVAsset();
Workaround.fromAsset(asset).loadValuesAsynchronously(NSArray.fromStrings("playable", "tracks"), () -> {
// done
});
}
static class Workaround extends AVAsset {
private Workaround(long handle) {
super((Handle) null, handle);
}
static Workaround fromAsset(AVAsset asset) {
return new Workaround(asset.getHandle());
}
@Method(selector = "loadValuesAsynchronouslyForKeys:completionHandler:")
public native void loadValuesAsynchronously(NSArray<NSString> keys, @Block Runnable handler);
}
Thank you!... it does work.