I have done a mobile app(live video streaming from mobile phone). Normally in mobile phones when the camera is in on the mobile backlight does not go to sleep mode but in my app i have written code to attach a camera and when i start to stream from the app then after some time the mobile goes to sleepmode. I need to make an application that should be able to make the phone light off when video is streaming. How can i achieve this ? Here is my code,
camera = null;
netStreamPublisher.attachCamera(null);
if (cameraPosition == "auto") {
camera = Camera.getCamera();
trace("Entered auto");
} else {
if (Camera.names.length == 1) {
camera = Camera.getCamera();
trace("Entered camera");
} else {
var tmpCamera:Camera = null;
trace("Entered");
for (var i:uint = 0; i < Camera.names.length; i++) {
tmpCamera = Camera.getCamera(Camera.names[i]);
if (tmpCamera.position == cameraPosition) {
camera = tmpCamera;
trace("Entered");
break;
}
}
}
}
if (camera) {
camera.setMode (640, 480, 15, true);
camera.setQuality (15000, 0); // 30000, 0 (adobe settings)
netStreamPublisher.attachCamera (camera);
return camera;
} else {
return null;
}
Import these classes...
import flash.desktop.NativeApplication;
import flash.desktop.SystemIdleMode;
Then set this to prevent the device from sleeping.
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
After you have used the camera you can if you wish, revert back to a sleepable mode with...
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.NORMAL