{"id":2515,"date":"2012-04-10T20:52:37","date_gmt":"2012-04-10T16:52:37","guid":{"rendered":"http:\/\/blog.denivip.ru\/?p=2515"},"modified":"2013-08-05T14:11:16","modified_gmt":"2013-08-05T10:11:16","slug":"2515","status":"publish","type":"post","link":"http:\/\/blog.denivip.ru\/index.php\/2012\/04\/2515\/?lang=en","title":{"rendered":"HTML5 Video VAST Plug-In"},"content":{"rendered":"<p><center><a href=\"http:\/\/blog.denivip.ru\/wp-content\/uploads\/2012\/02\/vae_banner.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.denivip.ru\/wp-content\/uploads\/2012\/02\/vae_banner.png\" alt=\"Video Ads HTML5\" title=\"vae_banner\" width=\"500\" height=\"200\" class=\"alignnone size-full wp-image-2483\" srcset=\"http:\/\/blog.denivip.ru\/wp-content\/uploads\/2012\/02\/vae_banner.png 500w, http:\/\/blog.denivip.ru\/wp-content\/uploads\/2012\/02\/vae_banner-300x120.png 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/center><\/p>\n<p>Today, almost every video content site is using inline advertising. However, no one would bother to say today of some upcoming massive shift from Adobe Flash Player to alternative solutions. Still, the HTML5 &lt;video&gt; tag is evidently becoming a matter of growing interest. Hence the issue of enabling advertising in the new context is emerging. Here we will show you a sample code of HTML5 video VAST plug-in to enable ads with a &quot;clean&quot; &lt;video&gt; tag. <!--more--> <\/p>\n<p>In our posts, we have many times mentioned the OpenX ad server. In the basic OpenX Video Plugin installation, the server outputs video ads in the VAST format that defines ad content parameters and methods used to respond to user actions. The timeframes to show an overlay or inline ad are defined by the video player. Therefore, we have to configure our OpenX server, prepare videos and create an HTML page to enable viewing. <a title=\"Displaying ads in OpenX\" href=\"http:\/\/blog.denivip.ru\/index.php\/2010\/07\/%D0%BF%D0%BE%D0%BA%D0%B0%D0%B7-%D1%80%D0%B5%D0%BA%D0%BB%D0%B0%D0%BC%D1%8B-%D0%B2-%D1%81%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D0%B5-openx\/\" target=\"_blank\">Here<\/a> you can find a screen cast describing how to launch an advertising campaign using OpenX. Below we are going to discuss how to create a viewing page.<\/p>\n<p>So let&#8217;s assume we have an HTML5 page containing a video embedded using a &lt;video&gt; tag:<\/p>\n<pre>&lt;!DOCTYPE html&gt;\r\n &lt;html&gt;\r\n &lt;head&gt;\r\n   &lt;title&gt;HTML5 javascript OpenX plug-in example&lt;\/title&gt;\r\n &lt;\/head&gt;\r\n &lt;body&gt;\r\n\t&lt;video id=&quot;example_video_1&quot; src=&quot;content\/bbb.mp4&quot;\r\n\t\t\twidth=&quot;640&quot; height=&quot;480&quot; controls \/&gt;\r\n\r\n &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>We are going to interrupt playback by showing video ads. Let&#8217;s add an &#8216;ads&#8217; attribute to the &lt;video&gt; tag  containing all the necessary information:<\/p>\n<pre>ads = ' {  &quot;servers&quot;: [\r\n                 {\r\n                    &quot;apiAddress&quot;: &quot;http:\/\/example.com\/openx\/www\/delivery\/fc.php&quot;\r\n                 }\r\n            ],\r\n           &quot;schedule&quot;: [\r\n                 {\r\n                    &quot;zone&quot;: &quot;11&quot;,\r\n                    &quot;position&quot;: &quot;pre-roll&quot;\r\n                 },\r\n                 {\r\n                    &quot;zone&quot;: &quot;11&quot;,\r\n                    &quot;position&quot;: &quot;mid-roll&quot;,\r\n                    &quot;startTime&quot;: &quot;00:00:08&quot;\r\n                 },\r\n                 {\r\n                    &quot;zone&quot;: &quot;11&quot;,\r\n                    &quot;position&quot;: &quot;mid-roll&quot;,\r\n                    &quot;startTime&quot;: &quot;00:06:00&quot;\r\n                 },\r\n                 {\r\n                    &quot;zone&quot;: &quot;11&quot;,\r\n                    &quot;position&quot;: &quot;post-roll&quot;\r\n                 }\r\n            ]\r\n         }'<\/pre>\n<p>The parameters we have entered are quite intuitive:<\/p>\n<ul>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:540px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">apiAddress<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>is the URL of your OpenX server ad delivery script<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:540px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">zone<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>is an OpenX zone ID used to fetch ads from<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:540px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">position<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>defines ad type (pre-roll, mid-roll, post-roll)<\/li>\n<li>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:540px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">startTime<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>is a start time of the ad relating to the main video timeline (for mid-rolls, format &#8212; &#8216;hh: mm: ss&#8217;)<\/li>\n<\/ul>\n<p>Having attached<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:540px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">html5videovastplugin.js<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>, add the<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:540px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">initAdsFor (&amp;quot;example_video_1&amp;quot;)<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>function call using our &lt;video&gt; element ID as a parameter. After that, our page code will look as follows:<\/p>\n<pre>&lt;!DOCTYPE html&gt;\r\n  &lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;HTML5 javascript OpenX plug-in example&lt;\/title&gt;\r\n    &lt;script src=&quot;html5videovastplugin.js&quot;&gt;&lt;\/script&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n\r\n   &lt;video id=&quot;example_video_1&quot; src=&quot;content\/bbb.mp4&quot;\r\n   width = &quot;640&quot; height=&quot;480&quot; controls\r\n   ads = ' {  &quot;servers&quot;: [\r\n                 {\r\n                    &quot;apiAddress&quot;: &quot;http:\/\/example.com\/openx\/www\/delivery\/fc.php&quot;\r\n                 }\r\n            ],\r\n           &quot;schedule&quot;: [\r\n                 {\r\n                    &quot;zone&quot;: &quot;11&quot;,\r\n                    &quot;position&quot;: &quot;pre-roll&quot;\r\n                 },\r\n                 {\r\n                    &quot;zone&quot;: &quot;11&quot;,\r\n                    &quot;position&quot;: &quot;mid-roll&quot;,\r\n                    &quot;startTime&quot;: &quot;00:00:08&quot;\r\n                 },\r\n                 {\r\n                    &quot;zone&quot;: &quot;11&quot;,\r\n                    &quot;position&quot;: &quot;mid-roll&quot;,\r\n                    &quot;startTime&quot;: &quot;00:06:00&quot;\r\n                 },\r\n                 {\r\n                    &quot;zone&quot;: &quot;11&quot;,\r\n                    &quot;position&quot;: &quot;post-roll&quot;\r\n                 }\r\n            ]\r\n         }'     \/&gt;\r\n\r\n   &lt;script&gt;initAdsFor(&quot;example_video_1&quot;);&lt;\/script&gt;\r\n\r\n &lt;\/body&gt;\r\n &lt;\/html&gt;<\/pre>\n<p><a title=\"HTML5 video with inline ads\" href=\"http:\/\/blog.denivip.ru\/demos\/html5videovastplugin\/example_static.html\" target=\"_blank\">View sample<\/a><\/p>\n<p>Please also note that currently the situation with format support by browsers is as follows:<\/p>\n<ul>\n<li>H.264 (MP4), AAC &#8212;\tSafari 3.0+, Chrome 5.0+, iOS 3.0+, Android 2.0+, IE 9.0+<\/li>\n<li>Theora (OGG), Vorbis &#8212;\tFireFox 3.5+, Chrome 5.0+, Opera 10.5+<\/li>\n<li>VP8 (WebM),Vorbis &#8212;\tIE 9.0+, FireFox 4.0+, Chrome 6.0+, Opera 10.6+,<\/li>\n<\/ul>\n<p>So, please be careful while preparing your videos and ads.<\/p>\n<p>The current version of the JavaScript module can be downloaded from the project page <a title=\"HTML5 Video VAST plug-in\" href=\"http:\/\/labs.denivip.ru\/projects\/html5videovastplugin\" target=\"_blank\">http:\/\/labs.denivip.ru\/projects\/html5videovastplugin<\/a>. <\/p>\n<p>Looking forward to your comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, almost every video content site is using inline advertising. However, no one would bother to say today of some upcoming massive shift from Adobe Flash Player to alternative solutions. Still, the HTML5 &lt;video&gt; tag is evidently becoming a matter of growing interest. Hence the issue of enabling advertising in the new context is emerging. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,20],"tags":[441,439,440],"_links":{"self":[{"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/posts\/2515"}],"collection":[{"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/comments?post=2515"}],"version-history":[{"count":7,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/posts\/2515\/revisions"}],"predecessor-version":[{"id":3255,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/posts\/2515\/revisions\/3255"}],"wp:attachment":[{"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/media?parent=2515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/categories?post=2515"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.denivip.ru\/index.php\/wp-json\/wp\/v2\/tags?post=2515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}