« Back to Product

Documentation

IPS_CreateMedia

 int IPS_CreateMedia (int $MediaType) 

Parameters

MediaType
Value Constant Description
0 MEDIATYPE_IPSVIEW creates an IPSView Form
1 MEDIATYPE_IMAGE creates an Image Object
2 MEDIATYPE_SOUND creates a Sound Object
3 MEDIATYPE_STREAM creates a Stream Object
4 MEDIATYPE_CHART creates a Chart Object
5 MEDIATYPE_DOCUMENT creates a Document Object

Returns

ID of the newly created media object

Description

The function creates an empty media object of the type MediaType.

The function returns an ID that uniquely identifies the created media object. After creation, the object is still empty and needs to be connected to a real media file using the function IPS_SetMediaFile.

Example

// Create a new media object with the name "Alarm"
$ImageFile = "media/Alarm_symbol.png";          // Image file (relative to the IP-Symcon main folder)
$MediaID = IPS_CreateMedia(MEDIATYPE_IMAGE);                  // create the image in the media pool
IPS_SetMediaFile($MediaID, $ImageFile, true);   // connect the image in the media pool with image file
IPS_SetName($MediaID, "Alarm");                 // Name media object
IPS_SetParent($MediaID, 12345);                 // Move media object below the object with the ID "12345"
Any questions?