如何检测接近传感器?

时间:2016-01-25 06:18:58

标签: ios objective-c avaudioplayer

如何检测用户是否听到此音频?

2 个答案:

答案 0 :(得分:0)

首先使用iPhone Proximity Sensor检测接近传感器的状态 然后使用电话扬声器Play audio through upper (phone call) speaker

播放音频

答案 1 :(得分:0)

[[UIDevice currentDevice] setProximityMonitoringEnabled:YES]
[[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(sensorStateChange:)
    name:@"UIDeviceProximityStateDidChangeNotification" object:nil];