Broadcast Intents

Orange Squeeze 2.0 and higher (and Orange Squeeze Preview 2.0 2013/10/28 and higher) will broadcast Android intents when track metadata changes or when players stop, start and pause. These intents follow the pattern of many other Android-based music apps, with a few customizations due to the fact that Orange Squeeze can be used to control many players. These intent broadcasts are designed to be consumed by 3rd-party apps that consume metadata from music players on Android devices. First, note that Orange Squeeze and Orange Squeeze Preview each broadcast under a separate action hierarchy. Orange Squeeze uses com.orangebikelabs.orangesqueeze whereas Orange Squeeze preview uses com.orangebikelabs.orangesqueezepreview. For further examples below, just make the appropriate translation of the action.

The app broadcasts two broad groups of intents:

  1. All players: if you are interested in receiving metadata for every player that Orange Squeeze recognizes, then use the com.orangebikelabs.orangesqueeze.all action prefix.
  2. Current player: if you only want to receive metadata for the “current” player that Orange Squeeze is viewing, then use the com.orangebikelabs.orangesqueeze action prefix.

For each intent prefix there are two separate types of events that will trigger a broadcast, and these correspond to the metachanged and the playstatechanged actions. In general, metachanged is broadcast at track boundaries, whereas playstatechanged is broadcast when the player stops, starts or pauses.

Putting it all together, your app might register for the following filter action:

com.orangebikelabs.orangesqueeze.all.metachanged

This action will receive metadata changes for all players that the Orange Squeeze app uses. Example: If you have three players, and they are all synced, then you will receive three consecutive broadcasts any time the metadata changes — one for each player in your sync group. If you are not inclined to do your own filtering of these events, you may want to consider using the current player prefix instead.

Various data will be included when the intent is broadcast. You can expect the following keys to be present. All values are just text strings, unless otherwise specified:

  • track
  • tracknumber (as a string, if present)
  • playerid (as a string, which happens to be a MAC address)
  • playername
  • artist
  • trackartist
  • albumartist
  • duration (as an integer, in ms)
  • position (as an integer, in ms)
  • ispaused (as a boolean, true/false)
  • isplaying (as a boolean, true/false)
Copyright © 2012-2024 Orange Bike Labs . All rights reserved.