[Previous] [Contents] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

Appendix: The phplay Remote Control Interface

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:

  1. Find phplay
  2. Fill in the remote message structure
  3. Send the message to phplay

Find phplay

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 );

Fill in the remote message structure

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:

CommandType
Valid commands that phplay accepts are:
KeypadNum
The track number phplay should play if plugin that's currently loaded is multitrack. This field is used in association with CMD_PLUGIN_ENTER.
bToDelete
A boolean that instructs phplay to delete from the file system, the URL contained in the newurl field of the MvRemoteMsg_t message, when the associated plugin is unloaded. This field is use in association with CMD_PLUGIN_OPEN_URLS.
newurl
String that contains the URL to be played (1023 char max). This field is used in association with CMD_PLUGIN_OPEN_URLS.

Send the message to phplay

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 );
    }
}

[Previous] [Contents] [Next]