Digital Video - January 2008 - (Page 32) AUDIENCE AWARENESS METERING VIEWERSHIP IS AN ESSENTIAL COMPONENT TO THE SUCCESS OF YOUR FLASH VIDEO PROJECT. BY NELS JOHNSON O kay, so Flash may now be God to some (in the Eric Clapton sense). One result of this theocracy is that several old Web video questions are new again: Who’s watching? How often? How far into the clip? Meaningful answers are of particular interest to Web 2.0 advertisers as ad revenue becomes the last best hope for sites that don't sell retail goods or promote social networks or are already cost centers for non-Web businesses. In the past, collecting online playback metrics was difficult, expensive and often unreliable. Now, thanks to advances in ActionScript and a software platform known as AJAX, any Web media producer with Flash Studio and basic HTML/Javascript (OK and PHP) skills can build a clip tracking system on a standard Web server at very little expense, The result is accurate, DIY viewership reporting. The keys to success are: 1) understanding how ActionScript in an embedded SWF file communicates media playback events to JavaScript on the same Web page, and 2) learning how JavaScript can use AJAX to automatically send those time and date-stamped events — perhaps including user geo and browser data — to a simple MySQL database. Armed with such capabilities, you can easily publish private Web pages for advertisers (and other authorized clients) who aggregate, collate and otherwise make sense of all that raw metered data. The rest of this story provides instructions on how to design and build a basic version of the system described above, including full source code and links to a sample working Web site. ACTIONSCRIPT/SWF FILE DEVELOPMENT First the media elements. Open a new .fla project in Flash Studio (I used Version 8 Professional in this example) then instantiate an FLVPlayback component with the following properties: name = vid, video window size = 320x240 (for example), position = upper left, autoplay = false. You can use defaults for the other properties but leave contentPath blank unless you don’t care about on-the-fly clip selection (demonstrated below). } function change_vid(new_vid):Void { vid.contentPath = new_vid; vid.addASCuePoint(10, "elapsed_time"); } function bigVideo():Void { vid.setSize(320,240); vid.x = 0; vid.y = 0; } function smallVideo():Void { vid.setSize(160,120); vid.y = 60; vid.x = 80; } listenerObject.complete = function(eventObject:Object):Void { ExternalInterface.call("playback_complete"); }; listenerObject.cuePoint = function(eventObject:Object):Void { ExternalInterface.call("cuepoint_alert"); }; vid.addEventListener("complete", listenerObject); vid.addEventListener("cuePoint", listenerObject); vid.contentPath = ""; ACTIONSCRIPT/SWF FILE DEVELOPMENT 32 import flash.external.ExternalInterface; ExternalInterface.addCallback("playVideo", null, playVideo); ExternalInterface.addCallback("pauseResume", null, pauseResume); ExternalInterface.addCallback("change_vid", null, change_vid); ExternalInterface.addCallback("bigVideo", null, bigVideo); ExternalInterface.addCallback("smallVideo", null, smallVideo); ExternalInterface.addCallback("playback_complete", this, end_vid); ExternalInterface.addCallback("cuepoint_alert", this, cuepoint_alert); var myFLV:String; var listenerObject:Object = new Object(); function playVideo():Void { vid.play(); } function pauseResume():Void { vid.pause(); dv january 2008 www.dv.com http://www.dv.com
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.