Yamaha MusicCast™ v0.1.7 MusicCast.Network.Entity

A module for managing MusicCast™ enabled devices.

A network entity is automatically started when a MusicCast enabled device is discovered. See the MusicCast.UPnP.SSDPClient for implementation details. Once started, the entity process is available to the network registry via it MusicCast device ID. See MusicCast.whereis/1 and MusicCast.which_devices/1 for more details about the network registry.

Each entity process keeps it state synchronized with the device it is paired with. This task is acomplished by the MusicCast.Network.EventListener process which forwards incoming YXC unicast messages to the affected entity processes. See MusicCast.subscribe/1 and MusicCast.unsubscribe/1 for more details.

Summary

Functions

Looks-up the value(s) for the given key(s)

Decreases the volume by step

Increases the volume by step

Mutes the volume

Plays the next track in the playback queue

Pauses playback of the current track

Begins playback of the current track

Begins playback of the current track URL

Plays the previous track in the playback queue

Stops playback

Selects the given input

Sets the volume to the given volume

Starts an entity as part of a supervision tree

Toggles playback state from :play to :pause and vice versa

Toggles repeat settings

Toggles repeat settings

Unmutes the volume

Types

device_id()
device_id() :: String.t
ip_address()
ip_address() :: {0..255, 0..255, 0..255, 0..255}
lookup_key()
lookup_key ::
  :host |
  :upnp |
  :device_id |
  :network_name |
  :available_inputs |
  :status |
  :playback
lookup_query()
lookup_query() :: :all | [lookup_key] | lookup_key
upnp_desc()
upnp_desc() :: Map.t

Functions

__lookup__(pid, keys \\ :all)
__lookup__(GenServer.server, lookup_query) :: [term] | term

Looks-up the value(s) for the given key(s).

decrease_volume(pid, step \\ 10)
decrease_volume(pid, Integer.t) :: :ok | {:error, term}

Decreases the volume by step.

increase_volume(pid, step \\ 10)
increase_volume(pid, Integer.t) :: :ok | {:error, term}

Increases the volume by step.

mute(pid)
mute(pid) :: :ok | {:error, term}

Mutes the volume.

playback_next(pid)
playback_next(pid) :: :ok | {:error, term}

Plays the next track in the playback queue.

playback_pause(pid)
playback_pause(pid) :: :ok | {:error, term}

Pauses playback of the current track.

playback_play(pid)
playback_play(pid) :: :ok | {:error, term}

Begins playback of the current track.

playback_play_url(pid, url, meta)
playback_play_url(pid, String.t, Enum.t) ::
  :ok |
  {:error, term}

Begins playback of the current track URL.

You can pass meta as a map or a keyword list:

iex> MusicCast.Network.Entity.playback_play_url(pid, url, title: "Cumbia Sobre el Mar", artist: "Quantic", album: "Dog with a Rope", duration: 377, mimetype: "audio/mp4")
:ok

A valid :mimetype field is mandatory, following fields are optional:

  • :title — Track title.
  • :album — Album name.
  • :album_cover_url — Album cover URL.
  • :artist — Artist name.
  • :duration — Track duration in second.

For implementation details, see MusicCast.UPnP.AVTransport.set_av_transport_uri/4.

playback_previous(pid)
playback_previous(pid) :: :ok | {:error, term}

Plays the previous track in the playback queue.

playback_stop(pid)
playback_stop(pid) :: :ok | {:error, term}

Stops playback.

select_input(pid, input)
select_input(pid, String.t) :: :ok | {:error, term}

Selects the given input.

To get a list of available inputs for a specific device, pass :available_inputs to __lookup__/2.

set_volume(pid, volume)
set_volume(pid, Integer.t) :: :ok | {:error, term}

Sets the volume to the given volume.

start_link(addr, upnp_desc, options \\ [])

Starts an entity as part of a supervision tree.

stop(pid)

See GenServer.stop/1.

toggle_play_pause(pid)
toggle_play_pause(pid) :: :ok | {:error, term}

Toggles playback state from :play to :pause and vice versa.

toggle_repeat(pid)
toggle_repeat(pid) :: :ok | {:error, term}

Toggles repeat settings.

toggle_shuffle(pid)
toggle_shuffle(pid) :: :ok | {:error, term}

Toggles repeat settings.

unmute(pid)
unmute(pid) :: :ok | {:error, term}

Unmutes the volume.