Add sound to play at time from NSDatePicker [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-12 06:59:54

问题


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?

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.


回答1:


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.



来源:https://stackoverflow.com/questions/32628729/add-sound-to-play-at-time-from-nsdatepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!