I'm following a low-budget project which cannot afford an expensive VAST Ads Server. Basically, what I have is a group of 5 videos to run as inline preroll. Not much important to track impressions and clicks.
I wrote a few lines of PHP to change randomly the video source and click link into a standard VAST 3.0 XML template.
What I'm missing is how to make the server respond to the video player requests with the XML file.
Here is my code.
Thanks!
$link_1 = 'https://example.com';
$link_2 = 'https://example.com';
$link_3 = 'https://example.com';
$link_4 = 'https://example.com';
$link_5 = 'https://example.com';
$srcvideo_1 = '/path-to-file/1.mp4/';
$srcvideo_2 = '/path-to-file/2.mp4/';
$srcvideo_3 = '/path-to-file/3.mp4/';
$srcvideo_4 = '/path-to-file/4.mp4/';
$srcvideo_5 = '/path-to-file/5.mp4/';
$min=1;
$max=5;
$sessionnum = rand($min,$max);
if ($sessionnum == '1') {
$link = $link_1;
$srcvideo = $srcvideo_1;
}
elseif ($sessionnum == '2') {
$link = $link_2;
$srcvideo = $srcvideo_2;
}
elseif ($sessionnum == '3') {
$link = $link_3;
$srcvideo = $srcvideo_3;
}
elseif ($sessionnum == '4') {
$link = $link_4;
$srcvideo = $srcvideo_4;
}
elseif ($sessionnum == '5') {
$link = $link_5;
$srcvideo = $srcvideo_15;
}
$output = '
<VAST version="3.0">
<Ad id="1">
<InLine>
<AdSystem>Adserver</AdSystem>
<AdTitle>VAST Ad</AdTitle>
<Impression id="12345689">
<![CDATA[ https://example.com/image.png?imp=1 ]]>
</Impression>
<Creatives>
<Creative sequence="1">
<Linear skipoffset="00:00:10">
<Duration>00:00:20</Duration>
<VideoClicks>
<ClickThrough>
<![CDATA[ ' . $link . ' ]]>
</ClickThrough>
<ClickTracking>
<![CDATA[ https://example.com/tracking ]]>
</ClickTracking>
</VideoClicks>
<MediaFiles>
<MediaFile width="426" height="240" delivery="progressive" type="video/mp4" bitrate="261" scalable="true" maintainAspectRatio="true">
<![CDATA[ ' . $srcvideo . ' ]]>
</MediaFile>
</MediaFiles>
</Linear>
</Creative>
</Creatives>
</InLine>
</Ad>
</VAST>
';
?>