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;