Poweramp API

repository·master·Indexed 43 days ago

https://github.com/maxmpz/powerampapi

SDKs and examples for extending Poweramp, featuring Intent-based APIs for playback control and state retrieval, a Content Provider for database queries, and a Lyrics Plugin API. It includes the Track Provider API based on Android SAF and DocumentsContract for injecting external, cloud-based, or streamed tracks into the Poweramp Library. Supports MediaSessionCompat and MediaBrowserCompat for Poweramp v3 (build 817+).

Tokens
10.9K
Snippets
19
Records
49
Agent score
56%

What's inside Poweramp API

  1. Overview of Poweramp APIs

    master

    Poweramp provides several different API surfaces depending on the type of extension or integration you are building. The available SDKs and integration methods include:

    • Skin SDK: For creating custom user interface skins.
    • Intent-based APIs: For interacting with Poweramp via Android Intents (includes support for Tasker and similar automation apps).
    • Visualization Presets: For creating custom visualizers.
    • Track Providers: For providing music tracks to Poweramp.
    • Lyrics Plugin: For providing lyrics data.
    • Album Art Loaders: (Status: TBD) For custom album art loading logic.

    For additional developer resources and community discussion, visit the Poweramp Developer Area.

  2. Overview of the Poweramp Lyrics Plugin API

    master

    Poweramp v3 (build 948+) allows third-party plugins to provide external lyrics (both plain text and LRC formats) for tracks currently playing in the player.

    The API operates using a broadcast-based intent system. Poweramp sends intents to your plugin, and your plugin responds by sending intents back to Poweramp. While referred to as 'broadcasts', these intents are sent to a single specific receiver (either the plugin application or the Poweramp application).

  3. Overview of Poweramp Intent-based APIs

    master

    Poweramp provides Intent-based APIs designed for simplicity and control. Developers can interact with Poweramp by sending Intents to perform actions or by listening to published Intents to retrieve the current state of the application.

    Key capabilities include:

    • Playback Control: Command Poweramp to play specific content.
    • Command Execution: Send instructions to Poweramp to perform various tasks.
    • State Retrieval: Access Poweramp's current state via published Intents.

    These Intents can be triggered programmatically within an application or via automation apps.

  4. Overview of the Poweramp Track Provider API

    master

    The Poweramp Track Provider API allows developers to inject external tracks into the Poweramp Library (including Folders and Folders Hierarchy). This is useful for providing cloud-based tracks, streamed/cached tracks, HTTP-hosted tracks, or virtual track hierarchies.

    Poweramp treats these tracks similarly to local file system tracks, adding a provider app name label to them. Depending on how the track is provided, different features are available:

    • File-backed tracks: If you provide a seekable file descriptor (e.g., a file on the local file system), features like the wave-seekbar, general seeking, and local tag reading work immediately.
    • URL tracks: You can provide URLs for almost any supported file format via HTTP(S) or HLS streams. You can also generate URLs dynamically during playback and provide custom headers or cookies.
    • Seekable sockets/pipes: For audio data requiring special preprocessing or decryption where a direct file descriptor is not possible, you can send audio data via seekable sockets using a custom protocol.
    • Playlists: Providers can offer m3u8 or pls playlists, which Poweramp processes into the 'Poweramp Streams' category and the 'Playlists' category.
  5. Provide Metadata and Album Art

    master

    You can provide metadata and album art using one of two approaches:

    1. Provider-Provided Metadata

    If you include MediaStore.MediaColumns.TITLE or MediaStore.MediaColumns.DURATION in your cursor, Poweramp assumes you are providing the metadata and will not attempt to scan the file itself.

    • Album Art: If Document.COLUMN_FLAGS contains Document.FLAG_SUPPORTS_THUMBNAIL, Poweramp will request the art via openDocumentThumbnail.
    • Lyrics: Can be provided via TrackProviderConsts.COLUMN_TRACK_LYRICS.

    2. Track-File Metadata

    If TITLE or DURATION are missing from your cursor, Poweramp will attempt to open the file via the file descriptor to extract tags and embedded album art itself.

  6. Receive Poweramp status updates via Broadcast Intents

    master

    Poweramp broadcasts status changes using the action com.maxmpz.audioplayer.STATUS_CHANGED. You can listen for this intent to react to playback changes.

    When the intent is received, it includes several extras that can be accessed directly (e.g., in automation apps like Tasker).

    Available Extras (Build 948+): Since build 948, track metadata is included directly in the STATUS_CHANGED extras. You can access:

    • %title
    • %album
    • %artist
    • (and other track info extras)

    Playback State Extras:

    • %state
    • %paused
    Action: com.maxmpz.audioplayer.STATUS_CHANGED
    
    Example variables:
    State=%state
    Paused=%paused
    Artist=%artist
    Title=%title
  7. How Poweramp scans Track Providers

    master

    Poweramp performs scanning in two distinct phases to build its library:

    1. Hierarchy Scan:

      • Establishes the folder and track hierarchy.
      • Adds new tracks and removes deleted ones from the database.
      • Updates last modified timestamps.
      • Uses a limited set of projection columns.
    2. Metadata Scan:

      • Retrieves detailed metadata for new or modified tracks (based on timestamps).
      • Uses a broader set of projection columns (though some, like lyrics, may still be excluded).

    Note on Loading: Poweramp does not support "Loading" cursors. You should provide ready-to-use cursors. If data loading is slow, you can block in your provider methods, but be aware of Poweramp's scan and openDocument timeouts (the latter is configurable by the user as "Network Timeout").

  8. Support Poweramp Equalizer in Skins

    master

    The Poweramp Equalizer can load Poweramp skins. To support the Equalizer, use the additional styles, attributes, and layouts specifically defined for it, which typically use a peq prefix or suffix.

    Note: When building your skin, you should still build against the Poweramp APK, as the Equalizer APK does not contain public definitions.

  9. Ensure skin option persistence with stable-ids.txt

    master

    Poweramp saves user settings based on the IDs generated for your skin's styles and attributes. If you perform a clean build and these IDs change, user settings will be lost.

    To prevent this, use a stable-ids.txt file. This file is automatically updated during the build process and should be kept in your project.

    Important: Only attributes used in your skins.xml <skin> tag's style attribute need stable IDs. For example, if you use <skin style="@style/SampleSkin">, your stable-ids.txt must contain a line like: com.poweramp.v3.sampleskin:style/SampleSkin = 0x80070054

  10. Implementation Model: Android SAF and DocumentsContract

    master

    The Poweramp Track Provider API is not a proprietary standalone API; instead, it is built upon standard Android APIs:

    1. Storage Access Framework (SAF)
    2. DocumentsContract

    Because it uses these standard interfaces, a provider plugin implemented for Poweramp can also be used by other Android applications (like Google Files or other file managers) that implement SAF/DocumentsContract client APIs. If you require your provider to be hidden from other apps, you must request this via a GitHub issue.

  11. Compare Poweramp v2 and v3 Skins

    master

    It is important to note that Poweramp v2 and v3 skins are not compatible with each other.

    FeaturePoweramp v2 Skins
    MechanismRelied on skin-provided layout XMLs.
    v3 MechanismRelies on style redefinitions.
    Layout ControlLayout XMLs cannot be changed by the skin (except for specific injected merge_ layouts).
    GraphicsUses more bitmap graphics.
    v3 GraphicsUses fewer bitmap graphics in default skins, though authors are not limited in using them.
  12. Manage FastTextView alignment and padding

    master

    For skins targeting Build 912+, new attributes are available for FastTextView (used for titles, meta, etc.) to simplify pixel-perfect alignment across different fonts and zoom levels:

    • layout_alignToContent: Forces alignment to the content, ignoring padding.
    • eatFontPads: Removes implicit vertical font paddings.

    To enable the new padding system in your skin, add allowNewPadding="true" to your <skin> element.

    Warning: If you redefine ItemTrackTitle or other ItemTrack** text styles, ensure you override all margin/alignment attributes (scale, padding, gravity) or remove overrides entirely to avoid broken layouts when using derived styles.