I am recording audio using AVAudioRecorder
,and now i want to get exact time duration of my recorded audio,how can i get that.
i have tried this:
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:avAudioRecorder.url options:nil];
CMTime time = asset.duration;
double durationInSeconds = CMTimeGetSeconds(time);
But my time
variable return NULL and durationInSeconds
return 'nan',what does that means by nan.
UPDATE
user1903074
answer have solved my problem but just for curiosity ,is thair any way to do it without AVAudioplayer
.
I am recording audio using AVAudioRecorder
,and now i want to get exact time duration of my recorded audio,how can i get that.
i have tried this:
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:avAudioRecorder.url options:nil];
CMTime time = asset.duration;
double durationInSeconds = CMTimeGetSeconds(time);
But my time
variable return NULL and durationInSeconds
return 'nan',what does that means by nan.
UPDATE
user1903074
answer have solved my problem but just for curiosity ,is thair any way to do it without AVAudioplayer
.
I am recording audio using AVAudioRecorder
,and now i want to get exact time duration of my recorded audio,how can i get that.
i have tried this:
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:avAudioRecorder.url options:nil];
CMTime time = asset.duration;
double durationInSeconds = CMTimeGetSeconds(time);
But my time
variable return NULL and durationInSeconds
return 'nan',what does that means by nan.
UPDATE
user1903074
answer have solved my problem but just for curiosity ,is thair any way to do it without AVAudioplayer
.
I am recording audio using AVAudioRecorder
,and now i want to get exact time duration of my recorded audio,how can i get that.
i have tried this:
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:avAudioRecorder.url options:nil];
CMTime time = asset.duration;
double durationInSeconds = CMTimeGetSeconds(time);
But my time
variable return NULL and durationInSeconds
return 'nan',what does that means by nan.
UPDATE
user1903074
answer have solved my problem but just for curiosity ,is thair any way to do it without AVAudioplayer
.
I am recording audio using AVAudioRecorder
,and now i want to get exact time duration of my recorded audio,how can i get that.
i have tried this:
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:avAudioRecorder.url options:nil];
CMTime time = asset.duration;
double durationInSeconds = CMTimeGetSeconds(time);
But my time
variable return NULL and durationInSeconds
return 'nan',what does that means by nan.
UPDATE
user1903074
answer have solved my problem but just for curiosity ,is thair any way to do it without AVAudioplayer
.
I am recording audio using AVAudioRecorder
,and now i want to get exact time duration of my recorded audio,how can i get that.
i have tried this:
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:avAudioRecorder.url options:nil];
CMTime time = asset.duration;
double durationInSeconds = CMTimeGetSeconds(time);
But my time
variable return NULL and durationInSeconds
return 'nan',what does that means by nan.
UPDATE
user1903074
answer have solved my problem but just for curiosity ,is thair any way to do it without AVAudioplayer
.
before you stop the recording, try get .currentTime
let duration = audioRecorder.currentTime
audioRecorder.stop()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.