I'm trying to create iPhone apps using Flash CS5.5 and I have a dou开发者_如何学Cbt. I just created a simple app which plays a long sound (more than 5 min).
When the phone auto-locks, my sounds stop. If I unlock the phone, my audio resumes.
What could I do to avoid the lock, or don't interrupt the sound when the device auto-locks?
[[UIApplication sharedApplication] setIdleTimerDisabled:YES]
set this for stoping lock the screen.
set this for stoping to lock the screen in ActionScript 3.0,
Import classes:
import flash.desktop.NativeApplication
import flash.desktop.SystemIdleMode;
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
Don't forget to check
WAKE_LOCK
in the permission in AIR settings,
If you want normal then use,
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.NORMAL;
To avoid the lock, you can look at idleTimerDisabled of UIApplication property. Or to run the sound even if the screen is locked, check the link below:
AVAudioPlayer will not play when device is locked
精彩评论