如何在通知扩展服务中播放声音?

时间:2019-02-16 17:11:11

标签: ios objective-c

我的代码:

NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"autumn_leaves" ofType:@"m4a"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];

NSError *error;
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL
                                               error:&error];
player.numberOfLoops = -1; //Infinite

[player play];

如何在通知扩展服务中使用avplayer播放声音?

0 个答案:

没有答案
相关问题