{"id":2327,"date":"2011-12-27T13:04:05","date_gmt":"2011-12-27T21:04:05","guid":{"rendered":"http:\/\/blog.mozilla.org\/webdev\/?p=2327"},"modified":"2011-12-28T07:33:57","modified_gmt":"2011-12-28T15:33:57","slug":"popcornjs_is_a-maize-ing","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/","title":{"rendered":"Bringing Firefox Alive with Popcorn.js"},"content":{"rendered":"<p>For most people who work with computers for a living, holidays are a time for family\u2026 and providing endless tech support. As I was huddled over a half working computer, someone asked what an add-on was. I spend most of my time working with and on add-ons \u2014 so the concept seems obvious to me. As I found out this past Christmas, it&#8217;s not to everyone. My otherwise-fairly-computer-literate family had a hard time understanding where the browser ended and websites such as Facebook or Google started \u2014 so explaining the concept of add-ons was not nearly as easy as I thought it would be.<\/p>\n<p>While over 85% of people using Firefox have at least one add-on installed, most people still don\u2019t really know what an add-on is or the possibilities they provide. To fix this, the add-ons group teamed up with <a href=\"https:\/\/twitter.com\/#!\/MozCreative\" target=\"_blank\">Mozilla Creative<\/a> and an outside firm, <a href=\"http:\/\/www.pokelondon.com\/\" target=\"_blank\">Poke<\/a>, to create a short video explaining what add-ons are and what they can do.<\/p>\n<p>After seeing the video, we knew we had to do something awesome with Popcorn.js.<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/services.addons.mozilla.org\/en-US\/firefox\/discovery\/pane\/8.0.1\/Darwin\" target=\"_blank\"><strong>Watch The Video<\/strong><\/a><br \/>\n<em>On the page, click &#8220;Learn More&#8221; to play the video.<\/em><\/p>\n<p>I recommend watching it in Firefox, since we interact with the browser in ways we couldn\u2019t with Chrome. You can also view the video directly inside Firefox, by going to <em>Tools &gt; Add-ons &gt; Get Add-ons &gt; Click &#8220;Learn More&#8221; \/ &#8220;Learn More About Add-ons&#8221;<\/em>.<\/p>\n<h2><strong>Popcorn.js<\/strong><\/h2>\n<p>For anyone unfamiliar, <a href=\"http:\/\/popcornjs.org\/\" target=\"_blank\">Mozilla\u2019s Popcorn.js<\/a> makes it easy to interact with video online using JavaScript. For anyone who has worked with jQuery or a similar library, it&#8217;s a breeze to pick up. Popcorn.js is the code part of <a href=\"http:\/\/mozillapopcorn.org\/\" target=\"_blank\">Mozilla&#8217;s Popcorn<\/a>, which is a larger project that aims to supplement video and audio with rich web content.<\/p>\n<p>Setting up Popcorn.js is incredibly simple:<\/p>\n<p><code>var pop = Popcorn('#promo-video');<\/code><\/p>\n<p>Popcorn.js has a plugin called <em>code<\/em>, which lets you run arbitrary code when the video hits certain points.<\/p>\n<p><code>pop.code({'start': start, 'end': end, 'onStart': function(){\u2026}, 'onEnd': function(){\u2026});<\/code><\/p>\n<p>That\u2019s basically all you need to know to get started with Popcorn.js. Everything else we did used regular JavaScript.<\/p>\n<p>Like I mentioned, we only used one of the many plugins. Popcorn.js is incredibly powerful, and our video barely scratched the surface of what <a href=\"http:\/\/popcornjs.org\/popcorn-docs\/plugins\/\" target=\"_blank\">Popcorn.js plugins can do<\/a>.<\/p>\n<h2>Showing Add-ons<\/h2>\n<p>We started by making add-ons fade in on the right side of the video when they are mentioned.<\/p>\n<p><em>Note: You will only see this in the video if your browser window is wide enough.<\/em><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/show-off.jpg\" onmouseover=\"this.src='http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/show-on.jpg'\" onmouseout=\"this.src='http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/show-off.jpg'\"><\/p>\n<h2>Previewing Personas<\/h2>\n<p>We\u2019re off to a good start. So far, we have add-ons showing up when they\u2019re mentioned in the video. Now, wouldn\u2019t it be cool if the video could interact with Firefox?<\/p>\n<p>At one point the video talks about <a href=\"https:\/\/addons.mozilla.org\/en-US\/firefox\/personas\/\" target=\"_blank\">Personas<\/a>, which are basically skins or backgrounds for Firefox. Since it would be incredibly annoying if any site you visited had the ability to skin your Firefox, the ability to trigger a preview is whitelisted to just the Mozilla add-ons sites.<\/p>\n<p><em>Note: You can add other sites to this whitelist by going into Preferences &gt; Security &gt; Exceptions.<\/em><\/p>\n<p>We thought it would be fun to style the browser with the Persona being mentioned \u2014 especially since we\u2019re the only site that is allowed by the browser to do this. We simply fire an event when the video hits a certain point. To make sure the Personas are displayed instantly, we pre-load the Personas when you first click \u201cPlay\u201d.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/persona-off.jpg\" onmouseover=\"this.src='http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/persona-on.jpg'\" onmouseout=\"this.src='http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/persona-off.jpg'\"><\/p>\n<h2>Blown Away<\/h2>\n<p>Later in the video, we see a plane fly across the screen. The papers and other items on the desk start to blow away as this happens. If you scroll down a bit, the add-ons below the video also start to flutter and are eventually caught in a JavaScript-y wind and blown away.<\/p>\n<p>This is done using <em><a href=\"https:\/\/developer.mozilla.org\/en\/CSS\/CSS_animations\" target=\"_blank\">-moz-animation<\/a><\/em> and <em><a href=\"https:\/\/developer.mozilla.org\/en\/CSS\/transform#section_7\" target=\"_blank\">-moz-transform: matrix()<\/a><\/em>. Each add-on is given a class of \u201cflutter\u201d (starting at a staggered interval), and the add-ons flutter back and forth until they eventually \u201cblow away\u201d.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/1524972.js?file=mozilla-flutter.css\"><\/script><\/p>\n<p>This isn&#8217;t Firefox-only; I just left out the Webkit code in the example for the sake of brevity.<\/p>\n<p>In the next scene, both the backdrop in the video and the add-ons on the site drop back into place.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/flutter.jpg\"><\/p>\n<h2>Other Things to Watch For<\/h2>\n<p>During the scene with the cameras, the page flashes as though a picture with a flash was being taken. The elements are simply hidden, then faded back in.<\/p>\n<p>When the video talks about how add-ons can translate a page, some of the text on the page is translated along with the text in the video. (Note: This only works if you have fewer than three add-ons installed or you watch using <a href=\"https:\/\/services.addons.mozilla.org\/en-US\/firefox\/discovery\/pane\/8.0.1\/Darwin\" target=\"_blank\">this link<\/a>. Otherwise, the top bar is not displayed.)<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/translate-off.jpg\" onmouseover=\"this.src='http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/translate-on.jpg'\" onmouseout=\"this.src='http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/translate-off.jpg'\"><\/p>\n<h2>Uh-oh<\/h2>\n<p>We learned a few things along the way. We used popcorn-complete.js, which we didn\u2019t realize loaded a few CSS, JS and SWF files off of popcornjs.org&#8217;s servers when the file was loaded. We mistakenly DOS\u2019d popcornjs.org, which in turn made the add-ons site load slowly. Thanks to <a href=\"http:\/\/jbuckley.ca\/\" target=\"_blank\">Jon Buckley<\/a> and <a href=\"http:\/\/twitter.com\/#%21\/rwaldron\" target=\"_blank\">Rick Waldron<\/a>, we were able to figure out what was going on and push a fix fairly quickly.<\/p>\n<p>I also owe Chris and Krupa a big hug when I get back to the Mozilla office \u2014 they helped me out a ton by finding and fixing a bunch of bugs as we were pushing to production, since I was an unfortunate 30,000 feet in the air as the video was going live.<\/p>\n<h2>Looking Ahead<\/h2>\n<p>I have no doubt that Popcorn.js is going to become huge as HTML5 video takes off. News sites will use it to show relevant links and tweets, fashion sites will link to online stores as a celebrity is shown wearing a dress or shirt, video sites will provide closed captioning and annotations, media sites will use it to sync viewing across multiple computers \u2014 the possibilities are endless. I cannot wait to see what Popcorn powered videos people make next.<\/p>\n<p style=\"text-align: center;\">\u00a0<a href=\"https:\/\/services.addons.mozilla.org\/en-US\/firefox\/discovery\/pane\/8.0.1\/Darwin\" target=\"_blank\"><strong>Watch The Video<\/strong><\/a><br \/>\n<em>On the page, click &#8220;Learn More&#8221; to play the video.<\/em><\/p>\n<p>Since the add-ons site is open source, be sure to <a href=\"https:\/\/github.com\/mozilla\/zamboni\/blob\/master\/media\/js\/zamboni\/discovery_video.js\" target=\"_blank\">view the code<\/a> if you&#8217;re interested.<\/p>\n<p>As for my family: not all is lost. The next morning I got an excited text from my cousin, who had watched the video. &#8220;Guess what I just did! I installed one of those picture addons on the top!&#8221; Sure, it pains me a bit that a <em>Justin Bieber<\/em> Persona now graces her Firefox \u2014 but hey, it&#8217;s a step in the right direction.<\/p>\n<p>&nbsp;<br \/>\n<img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/persona-on.jpg\" width=\"1\" height=\"1\"><br \/>\n<img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/show-on.jpg\" width=\"1\" height=\"1\"><br \/>\n<img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/translate-on.jpg\" width=\"1\" height=\"1\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For most people who work with computers for a living, holidays are a time for family\u2026 and providing endless tech support. As I was huddled over a half working computer, someone asked what an add-on was. I spend most of &hellip; <a class=\"go\" href=\"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/\">Continue reading<\/a><\/p>\n","protected":false},"author":269,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[288],"tags":[],"coauthors":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Bringing Firefox Alive with Popcorn.js - Mozilla Web Development<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Gregory Koberger\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/\",\"url\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/\",\"name\":\"Bringing Firefox Alive with Popcorn.js - Mozilla Web Development\",\"isPartOf\":{\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/show-off.jpg\",\"datePublished\":\"2011-12-27T21:04:05+00:00\",\"dateModified\":\"2011-12-28T15:33:57+00:00\",\"author\":{\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/#\/schema\/person\/8d3fbcbd19a1fc80e76a4ad481e517e2\"},\"breadcrumb\":{\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/#primaryimage\",\"url\":\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/show-off.jpg\",\"contentUrl\":\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/show-off.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog.mozilla.org\/webdev\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bringing Firefox Alive with Popcorn.js\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/#website\",\"url\":\"https:\/\/blog.mozilla.org\/webdev\/\",\"name\":\"Mozilla Web Development\",\"description\":\"For make benefit of glorious tubes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.mozilla.org\/webdev\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/#\/schema\/person\/8d3fbcbd19a1fc80e76a4ad481e517e2\",\"name\":\"Gregory Koberger\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/#\/schema\/person\/image\/228dcc5038736893bcdf50cba284a617\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0c98fd738dc3454f5a1649fdd25a8b87?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0c98fd738dc3454f5a1649fdd25a8b87?s=96&d=mm&r=g\",\"caption\":\"Gregory Koberger\"},\"description\":\"Gregory Koberger is a front- and back-end developer for addons.mozilla.org. You can view his portfolio at gkoberger.net, or follow him at @gkoberger.\",\"sameAs\":[\"http:\/\/gkoberger.net\"],\"url\":\"https:\/\/blog.mozilla.org\/webdev\/author\/gkobergermozilla-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Bringing Firefox Alive with Popcorn.js - Mozilla Web Development","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/","twitter_misc":{"Written by":"Gregory Koberger","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/","url":"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/","name":"Bringing Firefox Alive with Popcorn.js - Mozilla Web Development","isPartOf":{"@id":"https:\/\/blog.mozilla.org\/webdev\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/#primaryimage"},"image":{"@id":"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/#primaryimage"},"thumbnailUrl":"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/show-off.jpg","datePublished":"2011-12-27T21:04:05+00:00","dateModified":"2011-12-28T15:33:57+00:00","author":{"@id":"https:\/\/blog.mozilla.org\/webdev\/#\/schema\/person\/8d3fbcbd19a1fc80e76a4ad481e517e2"},"breadcrumb":{"@id":"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/#primaryimage","url":"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/show-off.jpg","contentUrl":"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/12\/show-off.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/blog.mozilla.org\/webdev\/2011\/12\/27\/popcornjs_is_a-maize-ing\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.mozilla.org\/webdev\/"},{"@type":"ListItem","position":2,"name":"Bringing Firefox Alive with Popcorn.js"}]},{"@type":"WebSite","@id":"https:\/\/blog.mozilla.org\/webdev\/#website","url":"https:\/\/blog.mozilla.org\/webdev\/","name":"Mozilla Web Development","description":"For make benefit of glorious tubes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.mozilla.org\/webdev\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.mozilla.org\/webdev\/#\/schema\/person\/8d3fbcbd19a1fc80e76a4ad481e517e2","name":"Gregory Koberger","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.mozilla.org\/webdev\/#\/schema\/person\/image\/228dcc5038736893bcdf50cba284a617","url":"https:\/\/secure.gravatar.com\/avatar\/0c98fd738dc3454f5a1649fdd25a8b87?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0c98fd738dc3454f5a1649fdd25a8b87?s=96&d=mm&r=g","caption":"Gregory Koberger"},"description":"Gregory Koberger is a front- and back-end developer for addons.mozilla.org. You can view his portfolio at gkoberger.net, or follow him at @gkoberger.","sameAs":["http:\/\/gkoberger.net"],"url":"https:\/\/blog.mozilla.org\/webdev\/author\/gkobergermozilla-com\/"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/posts\/2327"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/users\/269"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/comments?post=2327"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/posts\/2327\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/media?parent=2327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/categories?post=2327"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/tags?post=2327"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/coauthors?post=2327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}