I'd like to fade-out the sound played by MPMusicPlayerController
over a particular time period? How can I do this?
Asked
Active
Viewed 1,696 times
2

SundayMonday
- 19,147
- 29
- 100
- 154

Ali
- 10,774
- 10
- 56
- 83
-
Did you look at the volume method? – Bemmu Jun 18 '11 at 11:22
-
i want to fade it as fade continuously not simply slowing down the volume – Ali Jun 18 '11 at 11:45
1 Answers
6
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];
}
});

Jano
- 62,815
- 21
- 164
- 192
-
Dude, can we mix two songs? Like fading out current item and fading in next item? – Abdul Yasin Nov 11 '16 at 09:45
-
please see my comment above. I am in big trouble out here. Ay help is appreciated. – Abdul Yasin Nov 14 '16 at 07:13