OpenShot Audio Library | OpenShotAudio 0.3.2

Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
juce::RuntimePermissions Class Reference

`#include <juce_RuntimePermissions.h>`

## Public Types
enum | PermissionID { recordAudio = 1 , bluetoothMidi = 2 , readExternalStorage = 3 , writeExternalStorage = 4 , camera = 5 }
using | Callback = std::function< void(bool)>

## Static Public Member Functions
static void | request (PermissionID permission, Callback callback)
static bool | isRequired (PermissionID permission)
static bool | isGranted (PermissionID permission)

## Detailed Description

    Class to handle app runtime permissions for certain functionality on some platforms.

    The use of this class is currently only required if the app should run on
    Android API level 23 and higher.

    On lower API levels, the permissions are specified in the app manifest. On iOS,
    runtime permission requests are handled automatically by the Apple APIs and not
    manually in the app code. On Windows, OS X, and Linux, runtime permissions are not
    used at all. In all these cases, request() will simply call through to the
    callback with no overhead and pass true (making it safe to use on all platforms).

    For example, to enable audio recording on Android in your cross-platform app,
    you could modify your code as follows:

    Old code:

        audioDeviceManager.initialise (2, 2, nullptr, true, String(), nullptr);

    New code:

        RuntimePermissions::request (
            RuntimePermissions::audioRecording,
            [this] (bool wasGranted)
            {
                 if (! wasGranted)
                 {

e.g. display an error or initialise with 0 input channels return; }

audioDeviceManager.initialise (2, 2, nullptr, true, String(), nullptr); } );

Definition at line 64 of file juce_RuntimePermissions.h.

## Member Typedef Documentation

## ◆ Callback

using juce::RuntimePermissions::Callback = std::function<void(bool)>

Function type of runtime permission request callbacks.

Definition at line 94 of file juce_RuntimePermissions.h.

## Member Enumeration Documentation

## ◆ PermissionID

enum juce::RuntimePermissions::PermissionID

Enumerator
recordAudio | Permission to access the microphone (required on Android). You need to request this, for example, to initialise an AudioDeviceManager with a non-zero number of input channels, and to open the default audio input device.
bluetoothMidi | Permission to scan for and pair to Bluetooth MIDI devices (required on Android). You need to request this before calling BluetoothMidiDevicePairingDialogue::open(), otherwise no devices will be found.
readExternalStorage | Permission to read from external storage such as SD cards
writeExternalStorage | Permission to write to external storage such as SD cards
camera | Permission to use camera

Definition at line 68 of file juce_RuntimePermissions.h.

## Member Function Documentation

## ◆ isGranted()

bool juce::RuntimePermissions::isGranted | ( | PermissionID | permission | ) |
| static

Returns true if the app has been already granted this permission, either via a previous runtime request or otherwise, or no permission is necessary.

Note that this can be false even if isRequired returns false. In this case, the permission can not be obtained at all at runtime.

Definition at line 32 of file juce_RuntimePermissions.cpp.

## ◆ isRequired()

bool juce::RuntimePermissions::isRequired | ( | PermissionID | permission | ) |
| static

Returns whether a runtime request is required to obtain the permission on the current platform.

Definition at line 31 of file juce_RuntimePermissions.cpp.

## ◆ request()

void juce::RuntimePermissions::request | ( | PermissionID | permission,
|  | Callback | callback
| ) |  |
| static

Call this method to request a runtime permission.

Parameters

  permission | The PermissionID of the permission you want to request.
  callback | The callback to be called after the request has been granted or denied; the argument passed will be true if the permission has been granted and false otherwise.

If no runtime request is required or possible to obtain the permission, the callback will be called immediately. The argument passed in will be true if the permission is granted or no permission is required on this platform, and false otherwise.

If a runtime request is required to obtain the permission, the callback will be called asynchronously after the OS has granted or denied the requested permission (typically by displaying a dialog box to the user and waiting until the user has responded).

Definition at line 30 of file juce_RuntimePermissions.cpp.

The documentation for this class was generated from the following files:

- juce_RuntimePermissions.h
- juce_RuntimePermissions.cpp