Android is an open-source software stack for mobile devices. Developers can access the stack's code and even develop independent applications for free distribution or sale of Google Play. Android can be a lucrative platform for small businesses looking to expand their mobile presence. All you need to do to get started is learn a few basics, like embedding video with HTML.
As of the date of publication, HTML5 is the latest version of HTML and XHTML, focusing on addressing the needs of more interactive Web applications such as video and media embedding. Especially in the field of mobile development -- where Apple's decision not to support Flash-based media players on its popular iPhone and iPad platforms prompted a search for native Web alternatives -- the ability to embed and play videos directly from the HTML is a major change for developers. Along with a growing number of browsers and platforms, Android supports HTML5 embedded video.
While video files come packaged into a single file extension like .mp4 or .avi, a video files are actually containers with separate elements for audio and video information. HTML5 turns your Web browser into a video player, but it must also identify the codec used in the video file so that your Web browser knows how to decode the information. Android supports the H.264/MPEG-4 codec -- a standard used in most popular MP4 streaming services like YouTube -- so make sure to use video encoded with H.264 and identify the codec in your HTML for the browser.
The HTML for video embedding on an Android is rather simple. The code begins by stating the dimensions of the video, then provides a path to tell the browser where to find the video and, finally, identifies the codec and closes the command: <video width="280" height="170" controls> <source src="path/to/myvideo.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'> </video> Insert your desired dimensions for the embedded video and provide the directory where the video is stored on your Web server.
Even if you are designing an application primarily for the Android market, it's always a good idea to keep your options open and make your embedded video visible on other platforms and browsers. To do so, insert an <embed> tag in the HTML to fall back on a traditional Flash media player if the browser does not recognize the HTML5 <video> tag. Also provide instructions to decode alternate codecs like Theora. Both additions only require a few lines of code, and will not interfere with your video's Android functionality.
- Comstock Images/Comstock/Getty Images