@Mariusthvdb
I’ll take a moment to explain how it works in Premise, perhaps to serve as inspiration for Home Assistant’s developers to implement similar features. I think you’ll find this interesting.
In Premise, a MediaZone object is similar to Home Assistant’s media_player component. Both are an abstracted model of ‘stuff that plays media’. However, Premise’s MediaZone offers more functionality.
Before I explain a MediaZone object, I’ll take a moment to describe what’s shown in the Explorer pane (see top of image). It’s a hierarchical view of all (automated) objects in my home.
Home Assistant recently included support for Areas. In Premise they are called Locations and they can be organized in a hierarchy. It’s not just eye-candy; it’s used to define the physical location of everything. The ‘fully-qualified’ name of the KitchenMediaZone
object is:
Home.House.First.Kitchen.KitchenMediaZone
You can, for example, turn on all Light objects in Home.House.First.Kitchen
or turn off all MediaZone objects in Home.House.First
or turn off everything in Home.House
. Each Location has its own properties (like aggregated temperature and power-state). You don’t see it in this view but I also have a Home.Shed
and Home.Outside
.
In Home Assistant, a component has a state, attributes, and services. In Premise, an object has properties and methods (properties = state + attributes, methods = services). Referring to the image again, the Properties pane is currently showing all of the KitchenMediaZone’s properties (and methods). This is a live view like the States page in Home Assistant. However, unlike the States page, I can control the object by changing its properties in the Properties pane.
Imagine if Home Assistant’s States and Services pages were combined into one. That would be similar to (but still not equivalent) to what can be done in Premise’s Properties pane. For example, if I click anywhere on the Progress
property, I’ll cause the track to start playing from that position. The same is true for the Volume
property. If I click the Mute
checkbox it will, of course, mute the audio. If I wanted to do everything I just described with an automation it would look like this:
with Home.House.First.Kitchen.KitchenMediaZone
.Progress = 0.25
.Volume = 0.80
.Mute = true
end with
Now that we’ve had a brief introduction to Premise’s MediaZone, let’s look at two of its properties that would be useful in Home Assistant’s media_player.
PlayMode represents how the selected media should be played. The choices are:
-
NormalPlay
. Play all selected media in order then stop.
-
ContinuousPlay
. Play all selected media in order then repeat continuously.
-
RandomPlay
. Play all selected media in random order.
Duration represents the playing time of the selected media. Home Assistant has this attribute but n Premise you don’t have to begin playing the media to determine its duration, you only have to select it for playing (‘load the track’).
There are other properties like Fade (fade between tracks) but they are device-dependent. Premise’s MediaZone object is one of the most complex of all of its objects. It has a core set of properties and methods but then others become available (or unavailable) depending on the actual capabilities of the physical media-playing devices.
On more thing … the Content property can be a single track, an album, a collection of albums (such as by an artist), or a playlist. I use the words track and album but the concept also apply to videos.