Skip to main content

HiveMind media player agent protocol

Project description

HiveMind Media Player

Turn any device into a remotely controlled OVOS media player via HiveMind.

hivemind-media-player ships a HiveMindPlayerProtocol — a HiveMind agent protocol plugin (hivemind.agent.protocol) that runs the OVOS audio stack (ovos-audio + optional ovos-PHAL) locally and exposes it to any HiveMind client. Remote controllers send standard OCP (Open Voice OS Common Play) messages over the HiveMind encrypted WebSocket; the player device handles playback locally.

This is for devices that are not running a full OVOS instance — think a Raspberry Pi dedicated to being a networked speaker.

Architecture

remote controller           HiveMind (encrypted WebSocket)    this device
(Home Assistant,       <--------------------------------->    hivemind-core
 hivemind-player-ctl,                                         + HiveMindPlayerProtocol
 any OCP client)                                              + ovos-audio (TTS, OCP, VLC/MPV...)

The player agent answers no natural-language questions (natural_language_query yields only the end-of-query sentinel). Its sole role is to receive OCP/audio bus messages forwarded by hivemind-core and play them through the local audio stack.

Install

pip install hivemind-player-protocol

Optional extras (VLC, MPV backends):

pip install "hivemind-player-protocol[extras]"

Or from source:

git clone https://github.com/JarbasHiveMind/hivemind-media-player
cd hivemind-media-player
pip install -e .

Quickstart

1. Configure hivemind-core

Edit ~/.config/hivemind-core/server.json on the player device:

{
  "agent_protocol": {
    "module": "hivemind-player-agent-plugin",
    "hivemind-player-agent-plugin": {}
  }
}

2. Configure ovos-audio

Edit ~/.config/mycroft/mycroft.conf on the same device:

{
  "play_wav_cmdline": "paplay %1",
  "play_mp3_cmdline": "mpg123 %1",
  "play_ogg_cmdline": "ogg123 -q %1",
  "tts": {
    "module": "ovos-tts-plugin-server"
  },
  "Audio": {
    "backends": {
      "OCP": {
        "type": "ovos_common_play",
        "preferred_audio_services": ["mpv", "vlc"],
        "active": true
      },
      "vlc": { "type": "vlc", "active": true },
      "mpv": { "type": "mpv",  "active": true }
    }
  }
}

3. Create a client credential

On the player device (where hivemind-core will run):

hivemind-core add-client
# note the Access Key and Password printed

4. Grant OCP permissions

# replace 3 with your Node ID from add-client
hivemind-core allow-msg "ovos.common_play.play" 3
hivemind-core allow-msg "ovos.common_play.pause" 3
hivemind-core allow-msg "ovos.common_play.resume" 3
hivemind-core allow-msg "ovos.common_play.stop" 3
hivemind-core allow-msg "ovos.common_play.next" 3
hivemind-core allow-msg "ovos.common_play.previous" 3
hivemind-core allow-msg "speak" 3

See Permissions for the full list.

5. Set the identity on the controller

On the device that will send commands:

hivemind-client set-identity \
  --key <access_key> --password <password> \
  --host <player_device_ip> --port 5678 --siteid player

6. Start hivemind-core on the player device

hivemind-core listen

7. Control playback

python hivemind-player-ctl.py play "http://example.com/audio/track.mp3"
python hivemind-player-ctl.py pause
python hivemind-player-ctl.py resume
python hivemind-player-ctl.py next

Home Assistant / Music Assistant Integration

With hivemind-homeassistant, HiveMind player devices appear as media players in Home Assistant. Music Assistant can then browse and play music to them.

Related projects:

hivemind-player-ctl

hivemind-player-ctl.py is a CLI to control a running player. It requires only hivemind_bus_client and click.

Usage: python hivemind-player-ctl.py [OPTIONS] COMMAND

Options:
  --key TEXT       Access key (or read from identity file)
  --password TEXT  Password (or read from identity file)

Commands:
  play URI          Start playback of a URI
  pause             Pause
  resume            Resume
  stop              Stop
  next              Next track
  prev              Previous track
  shuffle.set       Enable shuffle
  shuffle.unset     Disable shuffle
  repeat.set        Enable repeat-all
  repeat.one        Enable repeat-one
  repeat.unset      Disable repeat
  interactive       Interactive shell

Permissions

Core audio

Message Purpose
speak TTS output
mycroft.audio.is_alive Health check
mycroft.audio.is_ready Readiness check
mycroft.stop Stop all audio

OCP (Open Voice OS Common Play)

Message Purpose
ovos.common_play.play Start playback
ovos.common_play.pause Pause
ovos.common_play.resume Resume
ovos.common_play.stop Stop
ovos.common_play.next Next track
ovos.common_play.previous Previous track
ovos.common_play.player.status Query player status
ovos.common_play.track_info Query track info
ovos.common_play.playlist.queue Queue a track
ovos.common_play.playlist.clear Clear the queue
ovos.common_play.set_track_position Seek
ovos.common_play.shuffle.set Enable shuffle
ovos.common_play.shuffle.unset Disable shuffle
ovos.common_play.repeat.set Enable repeat
ovos.common_play.repeat.unset Disable repeat
ovos.common_play.repeat.one Repeat one

PHAL (optional)

Message Purpose
mycroft.phal.is_alive PHAL health
mycroft.phal.is_ready PHAL readiness
mycroft.volume.get Query volume
mycroft.volume.set Set volume
mycroft.volume.increase Volume up
mycroft.volume.decrease Volume down
mycroft.volume.mute Mute
mycroft.volume.unmute Unmute

Documentation

License

Apache 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hivemind_player_protocol-0.0.0a3.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hivemind_player_protocol-0.0.0a3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file hivemind_player_protocol-0.0.0a3.tar.gz.

File metadata

File hashes

Hashes for hivemind_player_protocol-0.0.0a3.tar.gz
Algorithm Hash digest
SHA256 299d6a60747d6a20e3430be9272763c395c86e01e8b93419193105c11c804759
MD5 88133a9b088f47ac99c988b8d20570f3
BLAKE2b-256 6fe023d47cb7d5ab754e48c4f2ac24b28a46c079617889070708f632edff17d3

See more details on using hashes here.

File details

Details for the file hivemind_player_protocol-0.0.0a3-py3-none-any.whl.

File metadata

File hashes

Hashes for hivemind_player_protocol-0.0.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 d0b61ee23e57d04ba9081d896ce6558e73a55958ce10f8f169c9badd0e05bdfd
MD5 c2cefb7a1c6784cada2fe3b850810b1e
BLAKE2b-256 6bb3e7ce1667c058b8316598c6a8c790a49f4a66b2264ba45a855c4626921cfb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page