Package org.mpris

Class MPRIS

java.lang.Object
org.mpris.MPRIS
All Implemented Interfaces:
org.freedesktop.dbus.interfaces.DBusInterface, DBusProperties, MediaPlayer2, Player

public class MPRIS extends Object implements MediaPlayer2, Player, DBusProperties
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.mpris.mpris.MediaPlayer2

    MediaPlayer2.StringListType

    Nested classes/interfaces inherited from interface org.mpris.mpris.Player

    Player.MetadataType, Player.Seeked
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    emitSeeked(long positionInMicroseconds)
    Indicates that the track position has changed in a way that is inconsistant with the current playing state.
    org.freedesktop.dbus.types.Variant<?>
    Get(String interface_name, String property_name)
     
    Map<String,org.freedesktop.dbus.types.Variant<?>>
    GetAll(String interface_name)
     
     
     
     
    void
    Skips to the next track in the tracklist.
    void
    Opens the Uri given as an argument 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.
    void
    Pauses playback.
    void
    Starts or resumes playback.
    void
    Pauses playback.
    void
    Skips to the previous track in the tracklist.
    void
    Causes the media player to stop running.
    void
     
    void
    Seek(long x)
    Seeks forward in the current track by the specified number of microseconds.
    void
    Set(String interface_name, String property_name, org.freedesktop.dbus.types.Variant<?> value)
     
    void
    setCanGoNext(boolean canGoNext)
    Whether the client can call the Next method on this interface and expect the current track to change.
    void
    setCanGoPrevious(boolean canGoPrevious)
    Whether the client can call the Previous method on this interface and expect the current track to change.
    void
    setCanPause(boolean canPause)
    Whether playback can be paused using Pause or PlayPause.
    void
    setCanPlay(boolean canPlay)
    Whether playback can be started using Play or PlayPause.
    void
    setCanQuit(boolean canQuit)
    If false, calling Quit will have no effect, and may raise a NotSupported error.
    void
    setCanRaise(boolean canRaise)
    If false, calling Raise will have no effect, and may raise a NotSupported error.
    void
    setCanSeek(boolean canSeek)
    Whether the client can control the playback position using Seek and SetPosition.
    void
    setCanSetFullscreen(boolean canSetFullscreen)
    If false, attempting to set Fullscreen will have no effect, and may raise an error.
    void
    setDesktopEntry(String desktopEntry)
    The basename of an installed .desktop file which complies with the Desktop entry specification, with the ".desktop" extension stripped.
    void
    setFullscreen(boolean fullscreen)
    Whether the media player is occupying the fullscreen.
    void
    setHasTrackList(boolean hasTrackList)
    Indicates whether the /org/mpris/MediaPlayer2 object implements the org.mpris.MediaPlayer2.TrackList interface.
    void
    setIdentity(String identity)
    A friendly name to identify the media player to users.
    void
    The current loop / repeat status May be: "None" if the playback will stop when there are no more tracks to play "Track" if the current track will start again from the begining once it has finished playing "Playlist" if the playback loops through a list of tracks If CanControl is false, attempting to set this property should have no effect and raise an error.
    void
    setMaximumRate(double maximumRate)
    The maximum value which the Rate property can take.
    void
    The metadata of the current element.
    void
    setMinimumRate(double minimumRate)
    The minimum value which the Rate property can take.
    void
    The current playback status.
    void
    setPosition(long microseconds)
    The current track position in microseconds, between 0 and the 'mpris:length' metadata entry (see Metadata).
    void
    SetPosition(org.freedesktop.dbus.DBusPath Track_Id, long x)
    Sets the current track position in microseconds.
    void
    setRate(double rate)
    The current playback rate.
    void
    setShuffle(boolean shuffle)
    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.
    void
    setSupportedMimeTypes(String... supportedMimeTypes)
    The mime-types supported by the media player.
    void
    setSupportedUriSchemes(String... supportedUriSchemes)
    The URI schemes supported by the media player.
    void
    Replaces the TrackList implementation.
    void
    setVolume(double volume)
    The volume level.
    void
    Stops playback.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.freedesktop.dbus.interfaces.DBusInterface

    isRemote
  • Method Details

    • getPlaylists

      public PlaylistsImpl getPlaylists()
    • getTrackList

      public TrackListImpl getTrackList()
    • setCanQuit

      public void setCanQuit(boolean canQuit) throws org.freedesktop.dbus.exceptions.DBusException
      If false, calling Quit will have no effect, and may raise a NotSupported error. If true, calling Quit will cause the media application to attempt to quit (although it may still be prevented from quitting by the user, for example).
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setFullscreen

      public void setFullscreen(boolean fullscreen) throws org.freedesktop.dbus.exceptions.DBusException
      Whether the media player is occupying the fullscreen. This is typically used for videos. A value of true indicates that the media player is taking up the full screen. Media centre software may well have this value fixed to true If CanSetFullscreen is true, clients may set this property to true to tell the media player to enter fullscreen mode, or to false to return to windowed mode. If CanSetFullscreen is false, then attempting to set this property should have no effect, and may raise an error. However, even if it is true, the media player may still be unable to fulfil the request, in which case attempting to set this property will have no effect (but should not raise an error).

      This allows remote control interfaces, such as LIRC or mobile devices like phones, to control whether a video is shown in fullscreen.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setCanSetFullscreen

      public void setCanSetFullscreen(boolean canSetFullscreen) throws org.freedesktop.dbus.exceptions.DBusException
      If false, attempting to set Fullscreen will have no effect, and may raise an error. If true, attempting to set Fullscreen will not raise an error, and (if it is different from the current value) will cause the media player to attempt to enter or exit fullscreen mode. Note that the media player may be unable to fulfil the request. In this case, the value will not change. If the media player knows in advance that it will not be able to fulfil the request, however, this property should be false.

      This allows clients to choose whether to display controls for entering or exiting fullscreen mode.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setCanRaise

      public void setCanRaise(boolean canRaise) throws org.freedesktop.dbus.exceptions.DBusException
      If false, calling Raise will have no effect, and may raise a NotSupported error. If true, calling Raise will cause the media application to attempt to bring its user interface to the front, although it may be prevented from doing so (by the window manager, for example).
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setHasTrackList

      public void setHasTrackList(boolean hasTrackList) throws org.freedesktop.dbus.exceptions.DBusException
      Indicates whether the /org/mpris/MediaPlayer2 object implements the org.mpris.MediaPlayer2.TrackList interface.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setTrackList

      public void setTrackList(TrackListImpl trackList)
      Replaces the TrackList implementation. Only possible if TrackList support was added using the builder, as the exported D-Bus interfaces cannot be changed afterwards.
    • setIdentity

      public void setIdentity(String identity) throws org.freedesktop.dbus.exceptions.DBusException
      A friendly name to identify the media player to users. This should usually match the name found in .desktop files (eg: "VLC media player").
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setDesktopEntry

      public void setDesktopEntry(String desktopEntry) throws org.freedesktop.dbus.exceptions.DBusException
      The basename of an installed .desktop file which complies with the Desktop entry specification, with the ".desktop" extension stripped. Example: The desktop entry file is "/usr/share/applications/vlc.desktop", and this property contains "vlc"
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setSupportedUriSchemes

      public void setSupportedUriSchemes(String... supportedUriSchemes) throws org.freedesktop.dbus.exceptions.DBusException
      The URI schemes supported by the media player. This can be viewed as protocols supported by the player in almost all cases. Almost every media player will include support for the "file" scheme. Other common schemes are "http" and "rtsp". Note that URI schemes should be lower-case.

      This is important for clients to know when using the editing capabilities of the Playlist interface, for example.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setSupportedMimeTypes

      public void setSupportedMimeTypes(String... supportedMimeTypes) throws org.freedesktop.dbus.exceptions.DBusException
      The mime-types supported by the media player. Mime-types should be in the standard format (eg: audio/mpeg or application/ogg).

      This is important for clients to know when using the editing capabilities of the Playlist interface, for example.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setPlaybackStatus

      public void setPlaybackStatus(PlaybackStatus playbackStatus) throws org.freedesktop.dbus.exceptions.DBusException
      The current playback status. May be "Playing", "Paused" or "Stopped".
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setLoopStatus

      public void setLoopStatus(LoopStatus loopStatus) throws org.freedesktop.dbus.exceptions.DBusException
      The current loop / repeat status May be: "None" if the playback will stop when there are no more tracks to play "Track" if the current track will start again from the begining once it has finished playing "Playlist" if the playback loops through a list of tracks If CanControl is false, attempting to set this property should have no effect and raise an error.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setRate

      public void setRate(double rate) throws org.freedesktop.dbus.exceptions.DBusException
      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).

      This allows clients to display (reasonably) accurate progress bars without having to regularly query the media player for the current position.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setShuffle

      public void setShuffle(boolean shuffle) throws org.freedesktop.dbus.exceptions.DBusException
      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.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setMetadata

      public void setMetadata(Metadata metadata) throws org.freedesktop.dbus.exceptions.DBusException
      The 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.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setVolume

      public void setVolume(double volume) throws org.freedesktop.dbus.exceptions.DBusException
      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.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setPosition

      public void setPosition(long microseconds)
      The 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 inconstistant with the Rate property, the Seeked signal is emited.
      See Also:
    • setMinimumRate

      public void setMinimumRate(double minimumRate) throws org.freedesktop.dbus.exceptions.DBusException
      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.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setMaximumRate

      public void setMaximumRate(double maximumRate) throws org.freedesktop.dbus.exceptions.DBusException
      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.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setCanGoNext

      public void setCanGoNext(boolean canGoNext) throws org.freedesktop.dbus.exceptions.DBusException
      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.

      Even when playback can generally be controlled, there may not always be a next track to move to.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setCanGoPrevious

      public void setCanGoPrevious(boolean canGoPrevious) throws org.freedesktop.dbus.exceptions.DBusException
      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.

      Even when playback can generally be controlled, there may not always be a next previous to move to.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setCanPlay

      public void setCanPlay(boolean canPlay) throws org.freedesktop.dbus.exceptions.DBusException
      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.

      Even when playback can generally be controlled, it may not be possible to enter a "playing" state, for example if there is no "current track".
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setCanPause

      public void setCanPause(boolean canPause) throws org.freedesktop.dbus.exceptions.DBusException
      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.

      Not all media is pausable: it may not be possible to pause some streamed media, for example.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • setCanSeek

      public void setCanSeek(boolean canSeek) throws org.freedesktop.dbus.exceptions.DBusException
      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.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
      See Also:
    • emitSeeked

      public void emitSeeked(long positionInMicroseconds) throws org.freedesktop.dbus.exceptions.DBusException
      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.
      Also updates the Position property.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
    • Raise

      public void Raise()
      Specified by:
      Raise in interface MediaPlayer2
    • Quit

      public void Quit()
      Description copied from interface: MediaPlayer2
      Causes the media player to stop running. The media player may refuse to allow clients to shut it down. In this case, the CanQuit property is false and this method does nothing. Note: Media players which can be D-Bus activated, or for which there is no sensibly easy way to terminate a running instance (via the main interface or a notification area icon for example) should allow clients to use this method. Otherwise, it should not be needed. If the media player does not have a UI, this should be implemented.
      Specified by:
      Quit in interface MediaPlayer2
    • Next

      public void Next()
      Description copied from interface: Player
      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.
      Specified by:
      Next in interface Player
    • Previous

      public void Previous()
      Description copied from interface: Player
      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.
      Specified by:
      Previous in interface Player
    • Pause

      public void Pause()
      Description copied from interface: Player
      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.
      Specified by:
      Pause in interface Player
    • PlayPause

      public void PlayPause()
      Description copied from interface: Player
      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.
      Specified by:
      PlayPause in interface Player
    • Stop

      public void Stop()
      Description copied from interface: Player
      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.
      Specified by:
      Stop in interface Player
    • Play

      public void Play()
      Description copied from interface: Player
      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.
      Specified by:
      Play in interface Player
    • Seek

      public void Seek(long x)
      Description copied from interface: Player
      Seeks forward in the current track by the specified number of microseconds. 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.
      Specified by:
      Seek in interface Player
      Parameters:
      x - The number of microseconds to seek forward.
    • SetPosition

      public void SetPosition(org.freedesktop.dbus.DBusPath Track_Id, long x) throws org.freedesktop.dbus.exceptions.DBusException
      Description copied from interface: Player
      Sets the current track position in microseconds. 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.
      Specified by:
      SetPosition in interface Player
      Parameters:
      Track_Id - The currently playing track's identifier. If this does not match the id of the currently-playing track, the call is ignored as "stale". /org/mpris/MediaPlayer2/TrackList/NoTrack is not a valid value for this argument.
      x - Track position in microseconds. Between 0 and track length
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
    • OpenUri

      public void OpenUri(String Uri) throws org.freedesktop.dbus.exceptions.DBusException
      Description copied from interface: Player
      Opens the Uri given as an argument 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.
      Specified by:
      OpenUri in interface Player
      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.
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
    • getObjectPath

      public String getObjectPath()
      Specified by:
      getObjectPath in interface org.freedesktop.dbus.interfaces.DBusInterface
    • Get

      public org.freedesktop.dbus.types.Variant<?> Get(String interface_name, String property_name) throws org.freedesktop.dbus.exceptions.DBusException
      Specified by:
      Get in interface DBusProperties
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
    • GetAll

      public Map<String,org.freedesktop.dbus.types.Variant<?>> GetAll(String interface_name) throws org.freedesktop.dbus.exceptions.DBusException
      Specified by:
      GetAll in interface DBusProperties
      Throws:
      org.freedesktop.dbus.exceptions.DBusException
    • Set

      public void Set(String interface_name, String property_name, org.freedesktop.dbus.types.Variant<?> value) throws org.freedesktop.dbus.exceptions.DBusException
      Specified by:
      Set in interface DBusProperties
      Throws:
      org.freedesktop.dbus.exceptions.DBusException