File: flash.py

package info (click to toggle)
python-plyer 2.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,808 kB
  • sloc: python: 13,395; sh: 217; makefile: 177
file content (77 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# coding=utf-8
'''
Flash
=====

The :class:`Flash` provides access to public methods to use flash of your
device.

.. note::
    In android you need CAMERA, FLASHLIGHT permissions
    to access flash.

.. versionadded:: 1.2.5

This can be used to activate the flash of your camera on
Android and iOS.

Simple Examples
---------------

To turn on flash::

    >>> from plyer import flash
    >>> flash.on()

To turn off flash::

    >>> flash.off()

To release flash::

    >>> flash.release()

Supported Platforms
-------------------
Android, iOS

'''


class Flash:
    """
    Flash facade.
    """

    def on(self):
        """
        Activate the flash
        """
        self._on()

    def off(self):
        """
        Deactiavte the flash
        """
        self._off()

    def release(self):
        """
        Release any access to the Flash / Camera.
        Call this when you're done using the Flash.
        This will release the Camera, and stop any process.

        Next call to `_on` will reactivate it.
        """
        self._release()

    # private

    def _on(self):
        raise NotImplementedError()

    def _off(self):
        raise NotImplementedError()

    def _release(self):
        pass