如何以编程方式播放iOS标准“Tweet sent”声音?

时间:2012-12-28 09:54:54

标签: ios audio twitter

我正在使用TWTweetComposeViewController进行推文撰写。

然后我以这种方式手动发送推文:https://stackoverflow.com/a/14067278/440168

如何播放标准的“推文发送”声音通知?

1 个答案:

答案 0 :(得分:1)

此声音非常相似:http://soundjax.com/reddo/51828%5EWHISTLE.mp3

你可以这样玩:

NSError *error;
NSString *path        = [NSString stringWithFormat:@"%@/%@", NSBundle.mainBundle.resourcePath, @"whistle.mp3"];
NSUrl *url            = [NSURL fileURLWithPath:path isDirectory:NO];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:self.whistleUrl error:&error];

player.numberOfLoops = 0;
player.volume        = 0.4;

if (player == nil) {
    NSLog(@"%@", error.description);
    return;
}

[player play];