[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
Main page
## Usage 1. Launch Earpiece Player. 2. Select the audio source: * **Sample** — use the built-in `audio/sample.wav`; * **Audio File** — tap **File**, navigate to the folder and select an `.mp3` or `.wav` file. 3. Select the audio profile: `Player`, `Voicecall` or `Communication`. 4. Tap **Play**. The audio is played through the earpiece with the selected audio group. 5. When the audio resource is granted, the status message `Resources granted. Audio profile: ...` appears. Command-line usage: ```bash # Play the built-in sample with the Voicecall profile /usr/bin/ru.auroraos.EarpiecePlayer -p Voicecall # Play a file with the Communication profile /usr/bin/ru.auroraos.EarpiecePlayer -p Communication -f /home/defaultuser/Music/sample.wav ``` Use case diagram: ```text +---------------------------+ | Earpiece Player | +---------------------------+ | | | v v v +-----------+ +---------+ +----------------+ | Play | | Choose | | Select audio | | sample | | file | | profile | +-----------+ +---------+ +----------------+ ``` Aurora OS developer documentation: . ## Known issues and limitations * No known bugs that break the application at the moment. * On devices and emulators without an earpiece, the audio may be routed to the main speaker. * The command-line mode has no UI and exits automatically after playback. * The example intentionally sets `NEMO_RESOURCE_DISABLE=true` to control the resource policy explicitly; production applications should follow the platform resource policy guidelines. ## Project structure The project has a standard C++ and QML application structure for Aurora OS. * **[ru.auroraos.EarpiecePlayer.pro](ru.auroraos.EarpiecePlayer.pro)** file describes the project structure for the qmake build system. * **[audio](audio)** directory contains the built-in audio sample. * **[icons](icons)** directory contains the application icons for different screen resolutions. * **[qml](qml)** directory contains the QML source code and UI resources. * **[cover](qml/cover)** directory contains the application cover implementation. * **[dialogs](qml/dialogs)** directory contains the application dialogs. * **[icons](qml/icons)** directory contains the custom UI icons. * **[pages](qml/pages)** directory contains the application pages. * **[EarpiecePlayer.qml](qml/EarpiecePlayer.qml)** file provides the application window implementation. * **[rpm](rpm)** directory contains the RPM package build settings. * **[ru.auroraos.EarpiecePlayer.spec](rpm/ru.auroraos.EarpiecePlayer.spec)** file is used by the rpmbuild tool. * **[screenshots](screenshots)** directory contains the application screenshots. * **[src](src)** directory contains the C++ source code. * **[audiofileplayer.h](src/audiofileplayer.h)**, **[audiofileplayer.cpp](src/audiofileplayer.cpp)** — audio resource management and playback. * **[main.cpp](src/main.cpp)** file is the application entry point and command-line interface. * **[translations](translations)** directory contains the UI translation files. * **[resources.qrc](resources.qrc)** file lists the resources bundled into the application. * **[ru.auroraos.EarpiecePlayer.desktop](ru.auroraos.EarpiecePlayer.desktop)** file defines the display, permissions and launch parameters of the application. ## Terms of use and participation in development The source code of the project is provided under the [license](LICENSE.BSD-3-CLAUSE.md), which allows its use in third-party applications. The [Contributor Agreement](CONTRIBUTING.md) governs the rights granted by the participants to the Open Mobile Platform Company. Information about the participants is specified in the [AUTHORS](AUTHORS.md) file. The [Code of Conduct](CODE_OF_CONDUCT.md) is the current set of rules of the Open Mobile Platform Company, which informs about the expectations for interaction between community members when communicating and working on projects.