| 1 |
|
| 2 |
''' |
| 3 |
Flash |
| 4 |
===== |
| 5 |
|
| 6 |
The :class:`Flash` provides access to public methods to use flash of your |
| 7 |
device. |
| 8 |
|
| 9 |
.. note:: |
| 10 |
In android you need CAMERA, FLASHLIGHT permissions |
| 11 |
to access flash. |
| 12 |
|
| 13 |
.. versionadded:: 1.2.5 |
| 14 |
|
| 15 |
This can be used to activate the flash of your camera on |
| 16 |
Android and iOS. |
| 17 |
|
| 18 |
Simple Examples |
| 19 |
--------------- |
| 20 |
|
| 21 |
To turn on flash:: |
| 22 |
|
| 23 |
>>> from plyer import flash |
| 24 |
>>> flash.on() |
| 25 |
|
| 26 |
To turn off flash:: |
| 27 |
|
| 28 |
>>> flash.off() |
| 29 |
|
| 30 |
To release flash:: |
| 31 |
|
| 32 |
>>> flash.release() |
| 33 |
|
| 34 |
Supported Platforms |
| 35 |
------------------- |
| 36 |
Android, iOS |
| 37 |
|
| 38 |
''' |
| 39 |
|
| 40 |
|
| 41 |
class Flash: |
| 42 |
""" |
| 43 |
Flash facade. |
| 44 |
""" |
| 45 |
|
| 46 |
def on(self): |
| 47 |
""" |
| 48 |
Activate the flash |
| 49 |
""" |
| 50 |
self._on() |
| 51 |
|
| 52 |
def off(self): |
| 53 |
""" |
| 54 |
Deactiavte the flash |
| 55 |
""" |
| 56 |
self._off() |
| 57 |
|
| 58 |
def release(self): |
| 59 |
""" |
| 60 |
Release any access to the Flash / Camera. |
| 61 |
Call this when you're done using the Flash. |
| 62 |
This will release the Camera, and stop any process. |
| 63 |
|
| 64 |
Next call to `_on` will reactivate it. |
| 65 |
""" |
| 66 |
self._release() |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
def _on(self): |
| 71 |
raise NotImplementedError() |
| 72 |
|
| 73 |
def _off(self): |
| 74 |
raise NotImplementedError() |
| 75 |
|
| 76 |
def _release(self): |
| 77 |
pass |