从NSDatePicker添加声音以在播放时播放 [英] Add sound to play at time from NSDatePicker
问题描述
我正在创建一个项目,该项目要求用户能够设置在特定时间播放的声音,而我目前正在通过本地通知进行操作.我想将其更改为使用AVAudioPlayer
,我想知道什么是最好的方法?
I'm creating a project which requires the user to be able to set a sound to play at a specific time and I'm currently doing that with local notification. I would like to change that to use AVAudioPlayer
, and I was wondering, what would be the best approach?
此刻我得到的对象是NSDatePicker
和stringFromDate
字符串.我的目的是创建一个警报,以便用户可以使用NSDatePicker
设置时间,然后声音会消失.
The objects I've got at the moment are a NSDatePicker
and a stringFromDate
string. My aim is to create an alarm so that the user can set a time using the NSDatePicker
and at that time the sound will go off.
推荐答案
请使用Global变量或Class变量来播放警报.
Please use Global variable or Class variable to play the alarm.
@property AVAudioPlayer * player;
......
_player = [AVAudioPlayer alloc]...
[_player play];
对您的项目来说效果很好.
It'll works fine for your project.
这篇关于从NSDatePicker添加声音以在播放时播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!