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
BaseActions 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 BeaTunesgetApplication()Returns the main application component.StringgetId()Unique id for each instance of this object.static @NotNull PathgetPortFile()Returns the file name for the file that contains the current port number.voidinit()Initializes this component and its sub-components.voidsetApplication(BeaTunes beaTunes)Sets the main application component.voidshutdown()Shuts down this component and its sub-components.StringtoString()
-
-
-
Constructor Detail
-
RemoteControlService
public RemoteControlService(BeaTunes application)
-
-
Method Detail
-
setApplication
public void setApplication(BeaTunes beaTunes)
Description copied from interface:ApplicationComponentSets the main application component.- Specified by:
setApplicationin interfaceApplicationComponent<BeaTunes>- Parameters:
beaTunes- main application component
-
getApplication
public BeaTunes getApplication()
Description copied from interface:ApplicationComponentReturns the main application component.- Specified by:
getApplicationin interfaceApplicationComponent<BeaTunes>- Returns:
- application object
-
getId
public String getId()
Description copied from interface:ApplicationComponentUnique id for each instance of this object.- Specified by:
getIdin interfaceApplicationComponent<BeaTunes>- Returns:
- id
-
init
public void init()
Description copied from interface:ApplicationComponentInitializes this component and its sub-components.- Specified by:
initin 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 ShutdownVetoExceptionDescription copied from interface:ApplicationComponentShuts down this component and its sub-components.- Specified by:
shutdownin 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
-
-