デバイスにあるアルバムの全長を取得する必要がありますが、正しい結果が得られません。私が持っているのは、1つのアルバムの曲で配列を取得するための次のとおりです。
MPMediaPropertyPredicate *albumNamePredicate = [MPMediaPropertyPredicate predicateWithValue:albumTitle
forProperty: MPMediaItemPropertyAlbumTitle];
MPMediaQuery *myAlbumQuery = [[MPMediaQuery alloc] init];
[myAlbumQuery addFilterPredicate: albumNamePredicate];
songsAlbumList = [myAlbumQuery items];
曲の長さを取得するには、これを使用します。
NSNumber *songTrackLength = [song valueForProperty:MPMediaItemPropertyPlaybackDuration];
int minutes = floor([songTrackLength floatValue] / 60);
int seconds = trunc([songTrackLength floatValue] - minutes * 60);
TracklengthLabel.text = [NSString stringWithFormat:@"%d:%02d", minutes, seconds];
したがって、上記は正常に機能しますが、曲の長さを正しく追加できません...何かアイデアはありますか?