Generating Remote Control Events from my app

ぐ巨炮叔叔 提交于 2019-12-05 06:22:56

问题


I have two questions regarding Remote Control Events on iOS:

  1. I know that music applications are registered to remote control events and then can receive such events from the iPhone's player widget. Let's say I want my app to fire such events, is that possible?
  2. How does headphones for example generate those events?

回答1:


Without private API, you cannot send remotecontrol event to your application.

The reason is we cannot create such an Event (UIEvent) to send out by using:

[[UIApplication sharedApplication] sendEvent:anEvent];

You can, however save a registered event then play back by calling the above-function.




回答2:


I don't know if it possible for headphone events but with private API, you can send some events like: home button press, power button press or mouse events (not tested).

You should read this book:

http://www.amazon.com/gp/product/1118057651/ref=pd_lpo_sbs_dp_ss_1?pf_rd_p=1535523702&pf_rd_s=lpo-top-stripe-1&pf_rd_t=201&pf_rd_i=0321278542&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=0T2AMHJCEEKJN41YJHD5

It'll be a hard work to make this works.

Take a look at GSEvent to know how to send an event to OS (iOS).

Edit: I've found 2 event types in GSEvent.GSEventType:

kGSEventHeadsetButtonDown = 1018,
kGSEventHeadsetButtonUp = 1019,

PS: - this use private API so it will be rejected if you post this app to AppStore.



来源:https://stackoverflow.com/questions/23905163/generating-remote-control-events-from-my-app

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