本文介绍了我怎样才能淡出由MPMusicPlayerController播放的声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想淡出在特定时间内通过 MPMusicPlayerController
播放的声音? 我怎样才能做到这一点?
I'd like to fade-out the sound played by MPMusicPlayerController
over a particular time period? How can I do this?
推荐答案
有没有褪色的功能,所以你必须自己实现它。循环,直到体积为0,并添加一个延迟每个步骤。如果你想这一切都为2秒发生的未来,把code块上:
There is no fade functionality so you have to implement it yourself. Loop until volume is 0, and add a delay for each step. If you want all this to happen 2 seconds into the future, put the code on a block:
MPMusicPlayerController *iPod = [MPMusicPlayerController iPodMusicPlayer];
int64_t delay = 2LL * NSEC_PER_SEC;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,delay), dispatch_get_current_queue(), ^{
while (iPod.volume>.1){
iPod.volume -= .1;
[NSThread sleepForTimeInterval:0.1];
}
});
这篇关于我怎样才能淡出由MPMusicPlayerController播放的声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!