Documentation ¶
Index ¶
- Variables
- type LoopStatus
- type Metadata
- func (md Metadata) Find(key string) (dbus.Variant, bool)
- func (md Metadata) MPRISArtURL() (string, error)
- func (md Metadata) MPRISLength() (int64, error)
- func (md Metadata) MPRISTrackID() (dbus.ObjectPath, error)
- func (md Metadata) XESAMAlbum() (string, error)
- func (md Metadata) XESAMAlbumArtist() ([]string, error)
- func (md Metadata) XESAMArtist() ([]string, error)
- func (md Metadata) XESAMAsText() (string, error)
- func (md Metadata) XESAMAudioBPM() (int, error)
- func (md Metadata) XESAMAutoRating() (float64, error)
- func (md Metadata) XESAMComment() ([]string, error)
- func (md Metadata) XESAMComposer() ([]string, error)
- func (md Metadata) XESAMContentCreated() (time.Time, error)
- func (md Metadata) XESAMDiscNumber() (int, error)
- func (md Metadata) XESAMFirstUsed() (time.Time, error)
- func (md Metadata) XESAMGenre() ([]string, error)
- func (md Metadata) XESAMLastUsed() (time.Time, error)
- func (md Metadata) XESAMLyricist() ([]string, error)
- func (md Metadata) XESAMTitle() (string, error)
- func (md Metadata) XESAMTrackNumber() (int, error)
- func (md Metadata) XESAMURL() (string, error)
- func (md Metadata) XESAMUseCount() (int, error)
- func (md Metadata) XESAMUserRating() (float64, error)
- type PlaybackStatus
- type Player
- func (p Player) CanControl() (bool, error)
- func (p Player) CanGoNext() (bool, error)
- func (p Player) CanGoPrevious() (bool, error)
- func (p Player) CanPause() (bool, error)
- func (p Player) CanPlay() (bool, error)
- func (p Player) CanSeek() (bool, error)
- func (p Player) Close() error
- func (p Player) LoopStatus() (LoopStatus, error)
- func (p Player) MaximumRate() (float64, error)
- func (p Player) Metadata() (Metadata, error)
- func (p Player) MinimumRate() (float64, error)
- func (p Player) Next()
- func (p Player) OpenURI(uri string)
- func (p Player) Pause()
- func (p Player) Play()
- func (p Player) PlayPause()
- func (p Player) PlaybackStatus() (PlaybackStatus, error)
- func (p Player) Position() (int64, error)
- func (p Player) Previous()
- func (p Player) Rate() (float64, error)
- func (p Player) SeekTo(offset int64)
- func (p Player) Seeked(ctx context.Context) (<-chan int, error)
- func (p Player) SetLoopStatus(status LoopStatus) error
- func (p Player) SetPosition(trackID dbus.ObjectPath, position int64)
- func (p Player) SetRate(rate float64) error
- func (p Player) SetShuffle(shuffle bool) error
- func (p Player) SetVolume(volume float64) error
- func (p Player) Shuffle() (bool, error)
- func (p Player) Stop()
- func (p Player) Volume() (float64, error)
Constants ¶
This section is empty.
Variables ¶
var ErrTypeNotParsable = errors.New("the given type is not as expected")
Functions ¶
This section is empty.
Types ¶
type LoopStatus ¶
type LoopStatus string
const ( LoopStatusNone LoopStatus = "None" LoopStatusTrack LoopStatus = "Track" LoopStatusPlaylist LoopStatus = "Playlist" )
type Metadata ¶
type Metadata map[string]dbus.Variant
Metadata represents the mpris-metadata see: https://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata/
func (Metadata) MPRISArtURL ¶
MPRISArtURL returns the location of an image representing the track or album. Clients should not assume this will continue to exist when the media player stops giving out the URL.
func (Metadata) MPRISLength ¶
MPRISLength returns the duration of the track in microseconds.
func (Metadata) MPRISTrackID ¶
MPRISTrackID returns a unique identity for this track within the context of an MPRIS object (eg: tracklist).
func (Metadata) XESAMAlbum ¶
XESAMAlbum returns the album name.
func (Metadata) XESAMAlbumArtist ¶
XESAMAlbumArtist returns the album artist(s)
func (Metadata) XESAMArtist ¶
XESAMArtist returns the track artist(s).
func (Metadata) XESAMAsText ¶
XESAMAsText returns the track lyrics.
func (Metadata) XESAMAudioBPM ¶
XESAMAudioBPM returns the speed of the music, in beats per minute.
func (Metadata) XESAMAutoRating ¶
XESAMAutoRating returns an automatically-generated rating, based on things such as how often it has been played. This should be in the range 0.0 to 1.0.
func (Metadata) XESAMComment ¶
XESAMComment returns a (list of) freeform comment(s).
func (Metadata) XESAMComposer ¶
XESAMComposer returns the composer(s) of the track.
func (Metadata) XESAMContentCreated ¶
XESAMContentCreated returns when the track was created. Usually only the year component will be useful.
func (Metadata) XESAMDiscNumber ¶
XESAMDiscNumber returns the disc number on the album that this track is from.
func (Metadata) XESAMFirstUsed ¶
XESAMFirstUsed returns when the track was first played.
func (Metadata) XESAMGenre ¶
XESAMGenre returns the genre(s) of the track.
func (Metadata) XESAMLastUsed ¶
XESAMLastUsed returns when the track was last played.
func (Metadata) XESAMLyricist ¶
XESAMLyricist returns the lyricist(s) of the track.
func (Metadata) XESAMTitle ¶
XESAMTitle returns the track title.
func (Metadata) XESAMTrackNumber ¶
XESAMTrackNumber returns the track number on the album disc.
func (Metadata) XESAMUseCount ¶
XESAMUseCount returns hte number of times the track has been played.
func (Metadata) XESAMUserRating ¶
XESAMUserRating returns a user-specified rating. This should be in the range 0.0 to 1.0.
type PlaybackStatus ¶
type PlaybackStatus string
const ( PlaybackStatusPlaying PlaybackStatus = "Playing" PlaybackStatusPaused PlaybackStatus = "Paused" PlaybackStatusStopped PlaybackStatus = "Stopped" )
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player is a implementation of dbus org.mpris.MediaPlayer2.Player. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html Use NewPlayer to create a new instance with a connected session-bus via dbus.SessionBus. Use NewPlayerWithConnection when you want to use a self-configured dbus.Conn
func NewPlayer ¶
NewPlayer returns a new Player which is already connected to session-bus via dbus.SessionBus. Don't forget to Player.Close() the player after use.
func NewPlayerWithConnection ¶
NewPlayerWithConnection returns a new Player with the given name and connection. Deprecated: NewPlayerWithConnection will be removed in future (v2.X.X). Plain Struct initialization should be used instead. Private fields will be public.
func (Player) CanControl ¶
CanControl is true whether the media player may be controlled over this interface. This property is not expected to change, as it describes an intrinsic capability of the implementation. If this is false, clients should assume that all properties on this interface are read-only (and will raise errors if writing to them is attempted), no methods are implemented and all other properties starting with "Can" are also false. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:CanControl
func (Player) CanGoNext ¶
CanGoNext returns true whether the client can call the Next method on this interface and expect the current track to change. If it is unknown whether a call to Next will be successful (for example, when streaming tracks), this property should be set to true. If CanControl is false, this property should also be false. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:CanGoNext
func (Player) CanGoPrevious ¶
CanGoPrevious returns true whether the client can call the Previous method on this interface and expect the current track to change. If it is unknown whether a call to Previous will be successful (for example, when streaming tracks), this property should be set to true. If CanControl is false, this property should also be false. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:CanGoPrevious
func (Player) CanPause ¶
CanPause returns true whether playback can be paused using Pause or PlayPause. Note that this is an intrinsic property of the current track: its value should not depend on whether the track is currently paused or playing. In fact, if playback is currently paused (and CanControl is true), this should be true. If CanControl is false, this property should also be false. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:CanPause
func (Player) CanPlay ¶
CanPlay returns true whether playback can be started using Play or PlayPause. Note that this is related to whether there is a "current track": the value should not depend on whether the track is currently paused or playing. In fact, if a track is currently playing (and CanControl is true), this should be true. If CanControl is false, this property should also be false. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:CanPlay
func (Player) CanSeek ¶
CanSeek returns true whether the client can control the playback position using Seek and SetPosition. This may be different for different tracks. If CanControl is false, this property should also be false. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:CanSeek
func (Player) LoopStatus ¶
func (p Player) LoopStatus() (LoopStatus, error)
LoopStatus returns the current loop / repeat status May be: "None" as LoopStatusNone if the playback will stop when there are no more tracks to play "Track" as LoopStatusTrack if the current track will start again from the beginning once it has finished playing "Playlist" as LoopStatusPlaylist if the playback loops through a list of tracks If CanControl is false, attempting to set this property (SetLoopStatus) should have no effect and raise an error. https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:LoopStatus
func (Player) MaximumRate ¶
MaximumRate returns the maximum value which the Rate property can take. Clients should not attempt to set the Rate property above this value. This value should always be 1.0 or greater. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:MaximumRate
func (Player) Metadata ¶
Metadata of the current element. If there is a current track, this must have a "mpris:trackid" entry (of D-Bus type "o") at the very least, which contains a D-Bus path that uniquely identifies this track. See the type documentation for more details. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Metadata
func (Player) MinimumRate ¶
MinimumRate returns the minimum value which the Rate property can take. Clients should not attempt to set the Rate property below this value. Note that even if this value is 0.0 or negative, clients should not attempt to set the Rate property to 0.0. This value should always be 1.0 or less. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:MinimumRate
func (Player) Next ¶
func (p Player) Next()
Next skips to the next track in the tracklist. If there is no next track (and endless playback and track repeat are both off), stop playback. If playback is paused or stopped, it remains that way. If CanGoNext is false, attempting to call this method should have no effect. see: https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Next
func (Player) OpenURI ¶
OpenURI opens the Uri given as an argument Parameters: - uri (Uri of the track to load. Its uri scheme should be an element of the org.mpris.MediaPlayer2.SupportedUriSchemes property and the mime-type should match one of the elements of the org.mpris.MediaPlayer2.SupportedMimeTypes.) If the playback is stopped, starts playing If the uri scheme or the mime-type of the uri to open is not supported, this method does nothing and may raise an error. In particular, if the list of available uri schemes is empty, this method may not be implemented. Clients should not assume that the Uri has been opened as soon as this method returns. They should wait until the mpris:trackid field in the Metadata property changes. If the media player implements the TrackList interface, then the opened track should be made part of the tracklist, the org.mpris.MediaPlayer2.TrackList.TrackAdded or org.mpris.MediaPlayer2.TrackList.TrackListReplaced signal should be fired, as well as the org.freedesktop.DBus.Properties.PropertiesChanged signal on the tracklist interface. see: https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:OpenUri
func (Player) Pause ¶
func (p Player) Pause()
Pause pauses playback. If playback is already paused, this has no effect. Calling Play after this should cause playback to start again from the same position. If CanPause is false, attempting to call this method should have no effect. see: https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Pause
func (Player) Play ¶
func (p Player) Play()
Play starts or resumes playback. If already playing, this has no effect. If paused, playback resumes from the current position. If there is no track to play, this has no effect. If CanPlay is false, attempting to call this method should have no effect. see: https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Play
func (Player) PlayPause ¶
func (p Player) PlayPause()
PlayPause pauses playback. If playback is already paused, resumes playback. If playback is stopped, starts playback. If CanPause is false, attempting to call this method should have no effect and raise an error. see: https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:PlayPause
func (Player) PlaybackStatus ¶
func (p Player) PlaybackStatus() (PlaybackStatus, error)
PlaybackStatus returns the current playback status. May be "Playing" as PlaybackStatusPlaying, "Paused" as PlaybackStatusPaused or "Stopped" as PlaybackStatusStopped. https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:PlaybackStatus
func (Player) Position ¶
Position returns current track position in microseconds, between 0 and the 'mpris:length' metadata entry (see Metadata). Note: If the media player allows it, the current playback position can be changed either the SetPosition method or the Seek method on this interface. If this is not the case, the CanSeek property is false, and setting this property has no effect and can raise an error. If the playback progresses in a way that is inconsistent with the Rate property, the Seeked signal is emitted. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Position
func (Player) Previous ¶
func (p Player) Previous()
Previous skips to the previous track in the tracklist. If there is no previous track (and endless playback and track repeat are both off), stop playback. If playback is paused or stopped, it remains that way. If CanGoPrevious is false, attempting to call this method should have no effect. see: https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Previous
func (Player) Rate ¶
Rate return the current playback rate. The value must fall in the range described by MinimumRate and MaximumRate, and must not be 0.0. If playback is paused, the PlaybackStatus property should be used to indicate this. A value of 0.0 should not be set by the client. If it is, the media player should act as though Pause was called. If the media player has no ability to play at speeds other than the normal playback rate, this must still be implemented, and must return 1.0. The MinimumRate and MaximumRate properties must also be set to 1.0. Not all values may be accepted by the media player. It is left to media player implementations to decide how to deal with values they cannot use; they may either ignore them or pick a "best fit" value. Clients are recommended to only use sensible fractions or multiples of 1 (eg: 0.5, 0.25, 1.5, 2.0, etc). see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Rate
func (Player) SeekTo ¶
SeekTo seeks forward in the current track by the specified number of microseconds. Parameters: - offset (The number of microseconds to seek forward.) A negative value seeks back. If this would mean seeking back further than the start of the track, the position is set to 0. If the value passed in would mean seeking beyond the end of the track, acts like a call to Next. If the CanSeek property is false, this has no effect. see: https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Seek
func (Player) Seeked ¶ added in v0.1.0
Seeked indicates that the track position has changed in a way that is inconsistant with the current playing state. When this signal is not received, clients should assume that: - When playing, the position progresses according to the rate property. - When paused, it remains constant. This signal does not need to be emitted when playback starts or when the track changes, unless the track is starting at an unexpected position. An expected position would be the last known one when going from Paused to Playing, and 0 when going from Stopped to Playing. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Signal:Seeked
func (Player) SetLoopStatus ¶
func (p Player) SetLoopStatus(status LoopStatus) error
SetLoopStatus sets the current loop / repeat status May be: "None" as LoopStatusNone if the playback will stop when there are no more tracks to play "Track" as LoopStatusTrack if the current track will start again from the beginning once it has finished playing "Playlist" as LoopStatusPlaylist if the playback loops through a list of tracks If CanControl is false, attempting to set this property (SetLoopStatus) should have no effect and raise an error. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:LoopStatus
func (Player) SetPosition ¶
SetPosition Sets the current track position in microseconds. Parameters: - trackID (The currently playing track's identifier. If this does not match the id of the currently-playing track, the call is ignored as "stale".) - position (Track position in microseconds. This must be between 0 and <track_length>.) If this does not match the id of the currently-playing track, the call is ignored as "stale". If the Position argument is less than 0, do nothing. If the Position argument is greater than the track length, do nothing. If the CanSeek property is false, this has no effect. see: https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:SetPosition
func (Player) SetRate ¶
SetRate sets the current playback rate. The value must fall in the range described by MinimumRate and MaximumRate, and must not be 0.0. If playback is paused, the PlaybackStatus property should be used to indicate this. A value of 0.0 should not be set by the client. If it is, the media player should act as though Pause was called. If the media player has no ability to play at speeds other than the normal playback rate, this must still be implemented, and must return 1.0. The MinimumRate and MaximumRate properties must also be set to 1.0. Not all values may be accepted by the media player. It is left to media player implementations to decide how to deal with values they cannot use; they may either ignore them or pick a "best fit" value. Clients are recommended to only use sensible fractions or multiples of 1 (eg: 0.5, 0.25, 1.5, 2.0, etc). see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Rate
func (Player) SetShuffle ¶
SetShuffle set a value of false indicates that playback is progressing linearly through a playlist, while true means playback is progressing through a playlist in some other order. If CanControl is false, attempting to set this property should have no effect and raise an error. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Shuffle
func (Player) SetVolume ¶
SetVolume sets the volume level. When setting, if a negative value is passed, the volume should be set to 0.0. If CanControl is false, attempting to set this property should have no effect and raise an error. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Volume
func (Player) Shuffle ¶
Shuffle returns a value of false indicates that playback is progressing linearly through a playlist, while true means playback is progressing through a playlist in some other order. If CanControl is false, attempting to set this property should have no effect and raise an error. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Shuffle
func (Player) Stop ¶
func (p Player) Stop()
Stop stops playback. If playback is already stopped, this has no effect. Calling Play after this should cause playback to start again from the beginning of the track. If CanControl is false, attempting to call this method should have no effect and raise an error. see: https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Stop
func (Player) Volume ¶
Volume returns the volume level. When setting, if a negative value is passed, the volume should be set to 0.0. If CanControl is false, attempting to set this property should have no effect and raise an error. see: https://specifications.freedesktop.org/mpris-spec/2.2/Player_Interface.html#Property:Volume