Class RemoteControlService
- java.lang.Object
-
- com.tagtraum.beatunes.remotecontrol.RemoteControlService
-
- All Implemented Interfaces:
ApplicationComponent<BeaTunes>
public class RemoteControlService extends Object implements ApplicationComponent<BeaTunes>
Allows execution of
BaseAction
s obtained via ids fromActionManager
.To execute an action, connect to the loopback address (ipv4: 127.0.0.1) and send a UTF-8-encoded action id (see
ApplicationAction.getId()
) followed by a newline'\n'
.The port to connect to can be read from the file
getPortFile()
(ASCII encoded). The port may not stay stable between application restarts. The file should not exist, if beaTunes is not running.Connections from other IP addresses than the loopback address is not allowed.
The service usually responds with a simple, JSON-formatted status message.
Important ids are:
audioplayer.pause.play, audioplayer.next, audioplayer.previous, audioplayer.volume.up, audioplayer.volume.down, audioplayer.mute, audioplayer.pause, audioplayer.playing, audioplayer.track, audioplayer.image, audioplayer.love.toggle
.To list all possible action ids, use the id
list
.Ids may change without notice. You can obtain a complete set of registered action ids from
ActionManager.getActionIds()
.- Author:
- Hendrik Schreiber
- See Also:
RemoteControlClient
-
-
Constructor Summary
Constructors Constructor Description RemoteControlService(BeaTunes application)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BeaTunes
getApplication()
Returns the main application component.String
getId()
Unique id for each instance of this object.static @NotNull Path
getPortFile()
Returns the file name for the file that contains the current port number.void
init()
Initializes this component and its sub-components.void
setApplication(BeaTunes beaTunes)
Sets the main application component.void
shutdown()
Shuts down this component and its sub-components.String
toString()
-
-
-
Constructor Detail
-
RemoteControlService
public RemoteControlService(BeaTunes application)
-
-
Method Detail
-
setApplication
public void setApplication(BeaTunes beaTunes)
Description copied from interface:ApplicationComponent
Sets the main application component.- Specified by:
setApplication
in interfaceApplicationComponent<BeaTunes>
- Parameters:
beaTunes
- main application component
-
getApplication
public BeaTunes getApplication()
Description copied from interface:ApplicationComponent
Returns the main application component.- Specified by:
getApplication
in interfaceApplicationComponent<BeaTunes>
- Returns:
- application object
-
getId
public String getId()
Description copied from interface:ApplicationComponent
Unique id for each instance of this object.- Specified by:
getId
in interfaceApplicationComponent<BeaTunes>
- Returns:
- id
-
init
public void init()
Description copied from interface:ApplicationComponent
Initializes this component and its sub-components.- Specified by:
init
in interfaceApplicationComponent<BeaTunes>
-
getPortFile
@NotNull public static @NotNull Path getPortFile() throws IOException
Returns the file name for the file that contains the current port number. There is no guarantee, that the file actually exists. However, it should exists, if beaTunes is running.- Returns:
- file with port number
- Throws:
IOException
- if the file cannot be determined
-
shutdown
public void shutdown() throws ShutdownVetoException
Description copied from interface:ApplicationComponent
Shuts down this component and its sub-components.- Specified by:
shutdown
in interfaceApplicationComponent<BeaTunes>
- Throws:
ShutdownVetoException
- if this component wants to veto the shutdown. This exception is not guaranteed to be honored, i.e. a calling component may simply ignore it
-
-