Brian Hadaway

Professionally Nerdy Since 2002

OGG Files Causing Errors in HTML5 Audio Player in Firefox

About a year ago I created an HTML5 Audio Player with Flash Fallback that several developers have used in their sites. It’s not the most robust player, but what it lacks in features it makes up for in simplicity. It plays audio files natively in modern browsers and uses a simple Flash player to backfill audio tag functionality in antiquated browsers. The UI is styled with CSS regardless of whether the browser plays audio natively or via Flash and implementing the plugin is simple enough for novice developers.

Given the simplicity of the player, I was surprised when I recently received an email from someone asking me to help determine why my HTML5 Audio Player wouldn’t work for him in Firefox. He had seemingly configured everything correctly and the player worked in every other popular browser, but he still couldn’t get the player to work in Firefox. As it turns out most servers (including those used by GoDaddy) by default don’t serve the appropriate MIME Types for OGG files. That being the case, you’ll need set the appropriate MIME Types for OGG files if you want HTML5 audio players to work correctly in Firefox. So for an Apache server, you would need to add the following to your .htaccess file:

AddType audio/ogg .oga
AddType video/ogg .ogv
AddType application/ogg .ogg

Evidently, other browsers will guess the MIME Type based on file extension if a MIME Type isn’t served. I had just been lucky that all the servers I used up until this point were already configured to serve the right MIME Types.

If you want more info about this, check this page on the Mozilla Developer Network.

Posted in Front-End Development | Tagged , , , | Leave a comment

iPhone-Style Alphabetical Contact List with HTML, CSS and JavaScript (jQuery)

Here’s what you’re most likely looking for – the demo and the source. Feel free to read the explanation while you’re here.

Front-end developers are often called on to build UI elements that aren’t entirely original. Whether the cause of this phenomenon is a lack of creativity on the part of designers or a particular affinity for certain UI elements among the web-browsing public, ripping-off drawing inspiration from others’ ideas is common in web design. One of the most prominent sources of such “inspiration” over the past few years is Apple’s Aqua interface. Thanks to this glossy, semi-transparent, gradient-laden design, front-end and Flash developers have spent several years worth of billable hours creating simulated reflections and configuring cover flow components for clients insistent upon having sites that “look more web 2.0″. Read More »

Posted in Front-End Development, Labs | Tagged , , | 7 Comments

Responsive Web Design Using CSS3 Media Queries

Responsive web design is a type of progressive enhancement that uses fluid grids, flexible-size images and media queries to optimize a website for a users’ specific viewing context. At its core, responsive web design is about adjusting layout, typography and imagery to provide a consistent, device-independent web experience. Fluid grids and flexible size images aren’t new concepts to web design, so I’ll spend most of this post discussing media queries. Read More »

Posted in Front-End Development | Tagged , , , , , | 3 Comments

HTML5 Audio Player with Flash Fallback

UPDATE: If you want to use this with jQuery 1.7.1 you’ll need to change the following line in jquery.audiocontrol.js:
$player.remove(audio)
with
$player.remove("audio")
Thanks to Benjamin Desmarez at Guitar-Pro.com calling this bug to my attention.

I wanted to create a simple one-button audio player using HTML5 that would be suitable for playing samples of audio tracks. This one-button player would toggle between play, pause and loading states and would stop playing the current track when another instance of the button is clicked. Naturally, I would want to include a Flash fallback for browsers that don’t support HTML5 audio playback. I also wanted to use HTML/CSS to style a single set of controls that serve as the UI for both the HTML5 and Flash versions of the player.

What resulted from this exercise was a jQuery audiocontrol plugin that controls playback and an “invisible” Flash audio player that emulates the HTML5 <audio> element. The control lacks some necessary features such as support for playlists and “bundled” playback. This would allow users to listen to a group of tracks without continually clicking play. Also, there is currently no publicly-exposed method to kill audio playback from outside the control. This is also my first jQuery plugin so there’s probably some improvement to be made in that code. But it’s still a good basic HTML5 audio player with Flash fallback that allows you to style the buttons with CSS regardless of whether the audio is playing natively in the browser or in the Flash plugin.

The code is tested to work in the following browsers:

  1. Firefox 3.6 – Mac/PC
  2. Safari 5 – Mac
  3. Chrome 10 – Mac
  4. Internet Explorer 7+ – PC
  5. Firefox 4 – T-Mobile G2 (Android 2.2)
  6. Opera Mobile 11 – T-Mobile G2 (Android 2.2)
  7. Default Browser – T-Mobile G2 (Android 2.2)
  8. Safari Mobile – iPad and iPod Touch (iOS)

Take a look at a demo of my HTML5 audio player with Flash fallback here. Feel free to download the source or fork it on github and use it however you like. You’ll find some documentation in the jQuery plugin or you can hit me up with a comment or email if you have questions about how to customize this to your needs.

Update: If you want to see an example of the audio player in the wild check out TrumpetMoments.com. Dennis did a great job customizing the button to use on his site.

Posted in Labs | Tagged , , , , , | 60 Comments

Bloomberg Sports Front Office 2011

Bloomberg Sports Front Office 2011 is an RIA built with Flex that provides tools for fantasy baseball players. The application, powered by Bloomberg Sports’ statistical analysis and forecasting capabilities, contains a set of preseason and in-season tools that make draft, free-agent, trade and lineup optimization recommendations. Front Office 2011 syncs with ESPN, Yahoo and CBS fantasy leagues and gives casual fantasy baseball players like myself a simple alternative to my usual reactionary, guess-based approach to managing fantasy sports teams.

On this project, I was responsible for the front-end development of the marketing and ecommerce pages (built with Ruby on Rails) and the application wrapper pages (JSP). I was also one of three front-end Flex developers responsible for the styling the application. Under the guidance of senior Flex stylers, I used a combination of graphical and programmatic skinning along with SASS for the CSS which helped to organize and simplify the cumbersome stylesheets. I also wrote a few simple Flex components and worked with the hardcore Flex guys on developing some more complex components.

Posted in Work | Comments closed

Dear Java Developers

Dear Java Developers,

Please add a DOCTYPE to your JSPs. Firefox, Chrome and Safari are smart enough to figure it out, but Internet Explorer freaks out and goes into quirks mode when you don’t include a DOCTYPE. This makes everything look like crap in IE (more than usual) and results in lots of headaches for testers and front end developers. Read More »

Posted in Front-End Development, Quick Tips | Leave a comment

HTML5 Audio Support on Android Devices

UPDATE: Here’s a new post about a cross-browser HTML5 audio player with Flash fallback that effectively solves the problem described below.

In a previous post, I mentioned that I wanted to see first-hand how each browser renders default controls for the HTML5 audio element. I created a simple demo page and tested it in the following browsers:

  1. Firefox 4 – Mac (OSX 10.6)
  2. Safari 5 – Mac (OSX 10.6)
  3. Chrome 10 – Mac (OSX 10.6)
  4. Internet Explorer 9 – PC (Vista)
  5. Firefox 4 – T-Mobile G2 (Android 2.2)
  6. Opera Mobile 11 – T-Mobile G2 (Android 2.2)
  7. Default Browser – T-Mobile G2 (Android 2.2)
  8. Safari – iPad and iPod Touch (iOS)

As I tested the demo on the G2 in Android 2.2’s (aka Froyo) default browser I was surprised to see that I get neither the browser’s default controls nor the fallback message enclosed inside the audio element. How could this be? Read More »

Posted in Front-End Development | Tagged , , , , | 7 Comments

How HTML5 Audio Controls Render In Modern Browsers

I created a test page using the most basic implementation of the HTML5 audio tag so I could see how modern browsers render the default controls. (You can view my test page here.) As is the case with almost everything browser-related, there is quite a bit of discrepancy in how each browser renders the controls. What’s surprising is how mobile versions of browsers render controls differently from their desktop counterparts. Read More »

Posted in Front-End Development | Tagged , , | Leave a comment

Make @font-face Work on Android Devices

If you use FontSquirrel to generate @font-face kits you may have noticed that they abandoned the Smiley method of generating CSS in favor of newer methods like FontSpring or Mo Bulletproofer. This is great because CSS generated by FontSquirrel will now successfully render fonts in browsers on Android devices. Read More »

Posted in Front-End Development, Quick Tips | Tagged , , | 3 Comments

Flash Developer Job Interview Questions

I recently changed jobs. I interviewed with multiple people at several companies over the course of a few weeks. In all, I talked to 20-30 people about Flash Developer positions. While the task of juggling multiple interviews while still working for my former employer was quite challenging, I have to say that I really enjoyed the interviews themselves. It was fun to meet new like-minded people and talk to them about the state of development. Read More »

Posted in Flash, General | Tagged , , | 1 Comment