[RU](README.ru.md) | [**EN**](README.md) # Earpiece Player ## Description **Earpiece Player** is a demo application for Aurora OS that plays an audio sample (MP3 or WAV) through the earpiece (conversation speaker). It can be used as an example of working with the Resource Policy audio API and Qt Multimedia, and also as a small utility for checking audio routing to the earpiece. The example was created to demonstrate: * requesting and acquiring an audio resource with the Resource Policy API (`libresourceqt5`); * playing audio with `QMediaPlayer` in the audio group selected by the user; * combining a QML user interface and a command-line interface in one application. ## Features and API The application provides: * playback of a built-in audio sample; * selection and playback of an MP3 or WAV file stored on the device; * selection of the audio profile: `Player`, `Voicecall`, `Communication`; * display of the current audio resource state; * launch from the command line with the `-p/--audio-profile` and `-f/--file` options; * Russian and English UI localization. Demonstrated APIs: * **Resource Policy** (`libresourceqt5`) — `ResourcePolicy::AudioResource`, `ResourcePolicy::ResourceSet`, resource acquisition and release signals; * **Qt Multimedia** (`QMediaPlayer`) — audio playback and playback completion handling; * **Qt command line** (`QCommandLineParser`) — command-line interface; * **Sailfish Silica / `sailfishapp`** — Aurora OS application window and UI components. ### Libraries and frameworks used * `libresourceqt5` — Resource Policy and audio resource management; * Qt Multimedia (`Qt5Multimedia`) — audio playback; * Sailfish Silica and `sailfishapp` — Aurora OS UI framework; * Qt Quick/QML, Qt Core and Qt GUI — base Qt modules used by the application. ## Build status A CI/CD pipeline is not configured in this repository. The project is built locally with the Aurora SDK. ## Table of Contents - [Description](#description) - [Features and API](#features-and-api) - [Build status](#build-status) - [Detailed description](#detailed-description) - [Compatibility](#compatibility) - [Build features](#build-features) - [Branch information](#branch-information) - [Installation and launch](#installation-and-launch) - [Screenshots](#screenshots) - [Usage](#usage) - [Known issues and limitations](#known-issues-and-limitations) - [Project structure](#project-structure) - [Terms of use and participation in development](#terms-of-use-and-participation-in-development) ## Detailed description ### Audio resource management The `AudioFilePlayer` class ([src/audiofileplayer.h](src/audiofileplayer.h), [src/audiofileplayer.cpp](src/audiofileplayer.cpp)) is responsible for working with the Resource Policy API and audio playback. * `AudioFilePlayer::setAudioGroup()` ([src/audiofileplayer.cpp:26](src/audiofileplayer.cpp#L26)) creates a new `ResourcePolicy::ResourceSet` for the selected audio group, adds a `ResourcePolicy::AudioResource`, connects the `resourcesBecameAvailable`, `resourcesGranted` and `resourcesReleased` signals and calls `initAndConnect()`. * `AudioFilePlayer::createAudioResource()` ([src/audiofileplayer.cpp:83](src/audiofileplayer.cpp#L83)) sets the process ID and the `media.name` stream tag to `*`. * `AudioFilePlayer::audioProfileToAudioGroup()` ([src/audiofileplayer.cpp:62](src/audiofileplayer.cpp#L62)) maps the user-facing profile to a Resource Policy audio group: `Player` → `player`, `Voicecall` → `call`, `Communication` → `aliencall`. Any other value falls back to `player`. * `AudioFilePlayer::play()` ([src/audiofileplayer.cpp:43](src/audiofileplayer.cpp#L43)) creates a `QMediaPlayer`, sets the media URI and starts playback. The `playingFinished` signal is emitted when the media reaches `EndOfMedia` or on a playback error. * The constructor sets `NEMO_RESOURCE_DISABLE=true` ([src/audiofileplayer.cpp:19](src/audiofileplayer.cpp#L19)) so that the example manages the resource policy explicitly. ### Command-line interface [src/main.cpp](src/main.cpp) implements both application modes: * if arguments are passed, the application runs as a console application: `QCommandLineParser` parses `-p/--audio-profile` and `-f/--file`; after the audio resource is granted, the built-in sample or the specified file is played and the application exits when playback finishes; * without arguments, the application starts the QML UI, registers `AudioFilePlayer` as the `ru.auroraos.EarpiecePlayer` QML type and loads [qml/EarpiecePlayer.qml](qml/EarpiecePlayer.qml). ### User interface * [qml/pages/MainPage.qml](qml/pages/MainPage.qml) — source switches (sample or file), file chooser button, audio profile selector, playback button and resource status label. * [qml/dialogs/SelectFileDialog.qml](qml/dialogs/SelectFileDialog.qml) — file and folder browser based on `FolderListModel`; only `*.mp3` and `*.wav` files are shown. * [qml/cover/DefaultCoverPage.qml](qml/cover/DefaultCoverPage.qml) — application cover. * [audio/sample.wav](audio/sample.wav) — built-in sample bundled into the application through [resources.qrc](resources.qrc). ### Libraries and technologies * **Resource Policy (`libresourceqt5`)** manages access to device resources. An audio group determines how the audio stream is routed and which audio profile is used (`player`, `call`, `aliencall`). * **Qt Multimedia** provides `QMediaPlayer` for playing local files and `qrc` resources. * **Sailfish Silica / `sailfishapp`** provide the Aurora OS look and feel, application window, pages and dialogs. ## Compatibility The project is compatible with Aurora OS 5.1.5 and higher. It was built and tested with Aurora OS 5.1.5. ## Build features The project is built in the standard way using the Aurora SDK and qmake according to the [Build an example application](https://developer.auroraos.ru/doc/sdk/app_development/work/create/examples#build) instructions. Dependencies: * `sailfishapp` >= 1.0.2; * Qt 5 Core, QML, Quick and Multimedia; * `libresourceqt5`; * `desktop-file-utils` (for the RPM package). The `.pro` file uses `CONFIG += sailfishapp link_pkgconfig`, `PKGCONFIG += libresourceqt5` and `QT += multimedia`. Build notes: * if `pkg-config` reports that `libresourceqt5` is not found, install the Resource Policy development package in the Aurora SDK target and make sure that the `libresourceqt5.pc` file is available; * the `Audio` permission is required for playback and is already set in [ru.auroraos.EarpiecePlayer.desktop](ru.auroraos.EarpiecePlayer.desktop); * the `Music` permission is required to access audio files selected by the user; * no external modules, Conan packages or third-party prebuilt libraries are required. ## Branch information Application versions conform to the [branch naming convention](https://developer.auroraos.ru/doc/software_development/examples#branches). ## Installation and launch Build, install and run the application according to the [Example build](https://developer.auroraos.ru/doc/sdk/app_development/work/create/examples#build) instructions. ### Launch from the UI Open the application from the application list. The `Audio` permission is requested according to the `.desktop` file. ### Launch from the command line ```bash /usr/bin/ru.auroraos.EarpiecePlayer -p Voicecall -f ~/Music/sample.mp3 ``` Command-line options: | Option | Description | |--------|-------------| | `-p`, `--audio-profile` | Audio profile: `Player`, `Voicecall`, `Communication`. Default: `Player`. | | `-f`, `--file` | Path to an MP3 or WAV file. Absolute and relative paths are supported. If omitted, the built-in sample is played. | Additional launch conditions: * the audio file must be readable by the application (`Music` permission); * the device must have an earpiece for the intended audio routing; * no server or second application is required. ## Screenshots
![]() Main page |