1
assetURL = [item valueForProperty: MPMediaItemPropertyAssetURL];
NSLog(@"%@", assetURL); // asset url declares the song url and song path
AVURLAsset* audioAsset = [AVURLAsset URLAssetWithURL:assetURL options:nil]; // declare the audio asset url
CMTime audioDuration = audioAsset.duration; // get duration in cm time
double audioDurationSeconds = CMTimeGetSeconds(audioDuration); // convert audio duration in double
但是,這是一個問題,因爲我的音頻持續時間只有幾秒鐘,但我需要歌曲持續時間的「MM:SS」格式。如何獲取歌曲的實際時長,如「mm:ss」formate?
請幫幫我。提前致謝。
double song_length = [time doublevalue];我可以試試這個嗎? –
什麼是'時間'? –
NSString * time = [NSString stringWithFormat:@「%02ld:%02ld」,minutes,seconds]; –