"$wp" is a namespace that includes all interfaces of W Player API (e.g., content, device, local, utility, callback).

setDefaultCallback()

  • Description

    Add a Listener that receives events from W Player. To receive a state event regarding life cycle (e.g., ready, play, pageChanged, stop), you need to add a Listener during the stage of initial function creation.

  • Syntax

    function setDefaultCallback (myFunction(object));

  • Parameter

    An event is sent in object format as follows through callback.

State (ready)

{ 
type: 'state',
sub: 'ready',
data: {
/* user_data object */
}
name: 'name of Web Content element',
pageId: 'id'
}

'ready' State: Sends the time at which web content elements can use W Player API after all elements in a page are loaded. A web content element is loaded in iframe format, being in the Back Page layer which is a state in which the element is not displayed yet (and the previous content is playing on the current screen). Reset is possible as required, before the element appears on the screen.

data :{ /* user_data object*/ } user_data can be used for reset in ready state. (user_data can also be obtained through getProperty.)

State (play)

{ 
type: 'state',
sub: 'play',
name: 'name of Web Content element',
pageId: 'id'
}

'play' State: Sends the time at which the web content element appears on the screen (Front Page layer).

State (pageChanged)

{ 
type: 'state',
sub: 'pageChanged',
data: 'name of changed page',
name: 'name of Web Content element',
pageId: 'id'
}

'pageChanged' State: Sends the time at which a page transition takes place during playback. (This only works when the web content belongs to the common page.)

You can check which page has been switched by viewing the pageName included in the received data.

State (stop)

{ 
type: 'state',
sub: 'stop',
name: 'name of Web Content element',
pageId: 'id'
}

'stop' State: Sends the time before which web content element playback ends. Resources used in a web content element can be returned. (e.g., clearInterval, clearTimeout, $wp = null)

* A resource that is not returned properly may affect W Player playback due to a memory leak.

Error


{ 
type: 'error',
sub: 'name of error api',
data: {
/* custom error object */
}
}

'error' Type: Runs when a W Player API running error or other error occurs.

Error details can be viewed through the error object.

UDP

{ 
type: 'udp',
sub: 'number of udp port',
data: 'received data string from udp port'
}

'udp' Type: Runs after data is sent to UDP.

Port and other settings can be configured when authoring from Web Author.

{ 
type: 'datalink',
sub: 'name of datalink table',
data: {
/* data of datalink table */
}
}

'datalink' Type: Runs after data is sent from datalink.

Datalink information can be configured when authoring from Web Author.

  • Return value

    Type: void

  • Code example

    $wp.setDefaultCallback(object);

    Refer to the following: ▶ Receiving a state event