The phplay remote control interface gives any Photon application control over the behavior of the currently registered phplay.
To control phplay remotely, a Photon application must:
To ensure that only one instance of phplay listens for remote messages, a connector is created with a unique registered name ("phplay") when the first phplay instance is created.
Any Photon application can connect to phplay by calling the Photon library function PtConnectionFindName(). For example:
PtConnectionClient_t *client = PtConnectionFindName( "phplay", 0, 0 );
The MvRemote_t structure describes the messages received by phplay from remote applications.
typedef struct MvRemoteMsg
{
enum MvCommandType CommandType;
int KeypadNum;
int bToDelete;
char newurl[MV_MAX_URLLEN];
int reserve_1;
int reserve_2;
int reserve_3;
} MvRemoteMsg_t;
It contains at least the following members:
Here are some code examples that use the Photon library function PtConnectionSend().
Send an open URL command to phplay:
{
PtConnectionClient_t *client = PtConnectionFindName( "phplay", 0, 0 );
if( client )
{
MvRemoteMsg_t msg = {0};
msg.CommandType = CMD_PLUGIN_OPEN_URLS;
strcpy(msg.newurl, "http://www.sky.net/~jdeshon/jad0025a.wav");
// or strcpy(msg.newurl, "file:///var/media/revenge.wav");
// or strcpy(msg.newurl, "/var/media/revenge.wav");
PtConnectionSend( client, 0, &msg, 0, sizeof(msg), 0 );
}
}
Send a start command to phplay:
{
PtConnectionClient_t *client = PtConnectionFindName( "phplay", 0, 0 );
if( client )
{
MvRemoteMsg_t msg = {0};
msg.CommandType = CMD_PLUGIN_START;
PtConnectionSend( client, 0, &msg, 0, sizeof(msg), 0 );
}
}
Send a change track command to phplay:
{
PtConnectionClient_t *client = PtConnectionFindName( "phplay", 0, 0 );
if( client )
{
MvRemoteMsg_t msg = {0};
msg.CommandType = CMD_PLUGIN_ENTER;
msg.KeypadNum = 5; // go to track 5
PtConnectionSend( client, 0, &msg, 0, sizeof(msg), 0 );
}
}