From c579e768064bafb24ec2f16ca8132145b13704ec Mon Sep 17 00:00:00 2001 From: Frank Fundel Date: Thu, 19 Mar 2020 11:56:32 +0100 Subject: [PATCH] fixed iOS duration --- RNMusicMetadata/RNMusicMetadata.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/RNMusicMetadata/RNMusicMetadata.m b/RNMusicMetadata/RNMusicMetadata.m index aab2609..71a296e 100644 --- a/RNMusicMetadata/RNMusicMetadata.m +++ b/RNMusicMetadata/RNMusicMetadata.m @@ -55,11 +55,10 @@ -(NSDictionary *) getData:(NSString *)uri } } - NSURL *assetURL = [NSURL fileURLWithPath:uri]; - AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:assetURL error:nil]; - NSNumber *duration = [NSNumber numberWithDouble:[audioPlayer duration]]; + CMTime audioDuration = asset.duration; + NSNumber *duration = [NSNumber numberWithFloat:CMTimeGetSeconds(audioDuration)]; [songDictionary setValue:duration forKey:@"duration"]; - + [songDictionary setValue:uri forKey:@"uri"]; return songDictionary;