Receiving UDP data
Data received via the UDP port can be used.
- When authoring from Web Author, make sure the UDP Listener property is enabled under External Data. For details, see Configuring the W Player API settings.
- Simulate UDP actions by using the preview function in Web Author. For details, see About the W Player API simulation feature.
<html>
<head>
<script src="wplayer-api.1.0.0.js"></script>
<script>
let pageID = null;
const contentPropertyType = $wp.content.getPropertyType();
$wp.setDefaultCallback(function (object) {
switch (object.type) {
case 'state':
switch (object.sub) {
case 'ready':
pageID = object.pageId;
break;
}
break;
case 'udp':
$wp.content.getPage(pageID).getElement('Text1').setProperty(contentPropertyType.TEXT, `${object.data} from UDP`);
break;
default:
break;
}
});
</script>
</head>
</html>