开发者

How can I fade-out the sound played by MPMusicPlayerController?

I'd like to fade-out the sound played by MPMusicPlayerController over 开发者_如何转开发a particular time period? How can I do this?


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];
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜