EarpiecePlayer

EarpiecePlayer

Темы: AuroraOS
работа со звуком в OS Aurora

RU | EN

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

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 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) sets the process ID and the media.name stream 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 to player.
  • AudioFilePlayer::play() (src/audiofileplayer.cpp:43) 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) 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: 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.

User interface

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 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;
  • 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.

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 (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:

# 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=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 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.
  • screenshots directory contains the application screenshots.
  • src directory contains the C++ source code.
  • 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.