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
QMediaPlayerin 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-profileand-f/--fileoptions; - 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
- Features and API
- Build status
- Detailed description
- Compatibility
- Build features
- Branch information
- Installation and launch
- Screenshots
- Usage
- Known issues and limitations
- Project structure
- Terms of use and participation in development
Detailed description
Audio resource management
The AudioFilePlayer class (src/audiofileplayer.h, src/audiofileplayer.cpp) is responsible for working with the Resource Policy API and audio playback.
-
AudioFilePlayer::setAudioGroup()(src/audiofileplayer.cpp:26) creates a newResourcePolicy::ResourceSetfor the selected audio group, adds aResourcePolicy::AudioResource, connects theresourcesBecameAvailable,resourcesGrantedandresourcesReleasedsignals and callsinitAndConnect(). -
AudioFilePlayer::createAudioResource()(src/audiofileplayer.cpp:83) sets the process ID and themedia.namestream tag to*. -
AudioFilePlayer::audioProfileToAudioGroup()(src/audiofileplayer.cpp:62) maps the user-facing profile to a Resource Policy audio group:Player→player,Voicecall→call,Communication→aliencall. Any other value falls back toplayer. -
AudioFilePlayer::play()(src/audiofileplayer.cpp:43) creates aQMediaPlayer, sets the media URI and starts playback. TheplayingFinishedsignal is emitted when the media reachesEndOfMediaor on a playback error. - The constructor sets
NEMO_RESOURCE_DISABLE=true(src/audiofileplayer.cpp:19) so that the example manages the resource policy explicitly.
Command-line interface
src/main.cpp implements both application modes:
- if arguments are passed, the application runs as a console application:
QCommandLineParserparses-p/--audio-profileand-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
AudioFilePlayeras theru.auroraos.EarpiecePlayerQML type and loads qml/EarpiecePlayer.qml.
User interface
- 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 — file and folder browser based on
FolderListModel; only*.mp3and*.wavfiles are shown. - qml/cover/DefaultCoverPage.qml — application cover.
- audio/sample.wav — built-in sample bundled into the application through 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
QMediaPlayerfor playing local files andqrcresources. -
Sailfish Silica /
sailfishappprovide 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 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-configreports thatlibresourceqt5is not found, install the Resource Policy development package in the Aurora SDK target and make sure that thelibresourceqt5.pcfile is available; - the
Audiopermission is required for playback and is already set in ru.auroraos.EarpiecePlayer.desktop; - the
Musicpermission 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.
Installation and launch
Build, install and run the application according to the Example 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
/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 (
Musicpermission); - the device must have an earpiece for the intended audio routing;
- no server or second application is required.
Screenshots
![]() Main page |
Usage
- Launch Earpiece Player.
- Select the audio source:
-
Sample — use the built-in
audio/sample.wav; -
Audio File — tap File, navigate to the folder and select an
.mp3or.wavfile.
-
Sample — use the built-in
- Select the audio profile:
Player,VoicecallorCommunication. - Tap Play. The audio is played through the earpiece with the selected audio group.
- When the audio resource is granted, the status message
Resources granted. Audio profile: ...appears.
Command-line usage:
# 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:
+---------------------------+
| Earpiece Player |
+---------------------------+
| | |
v v v
+-----------+ +---------+ +----------------+
| Play | | Choose | | Select audio |
| sample | | file | | profile |
+-----------+ +---------+ +----------------+
Aurora OS developer documentation: https://developer.auroraos.ru/doc.
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=trueto 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 file describes the project structure for the qmake build system.
- audio directory contains the built-in audio sample.
- icons directory contains the application icons for different screen resolutions.
-
qml directory contains the QML source code and UI resources.
- cover directory contains the application cover implementation.
- dialogs directory contains the application dialogs.
- icons directory contains the custom UI icons.
- pages directory contains the application pages.
- EarpiecePlayer.qml file provides the application window implementation.
-
rpm directory contains the RPM package build settings.
- ru.auroraos.EarpiecePlayer.spec file is used by the rpmbuild tool.
- screenshots directory contains the application screenshots.
-
src directory contains the C++ source code.
- audiofileplayer.h, audiofileplayer.cpp — audio resource management and playback.
- main.cpp file is the application entry point and command-line interface.
- translations directory contains the UI translation files.
- resources.qrc file lists the resources bundled into the application.
- 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, which allows its use in third-party applications.
The Contributor Agreement governs the rights granted by the participants to the Open Mobile Platform Company.
Information about the participants is specified in the AUTHORS file.
The Code of Conduct 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.
