HTML and CSS Reference
In-Depth Information
Supported Media Formats
Not all media formats will work on Android. Table 3-2 shows the formats that
should work with most, if not all, Android handsets.
Table 3-2. Supported HTML5 Audio Formats
Format
Mime Type
File Name Extension
OGG Vorbis Audio
application/ogg
.ogg
MP4 Audio
audio/mp4
.m4a, .mp4, .3gp, .aac
WMA Audio
audio/x-ms-wma
.wma
MP3 Audio
audio/mpeg
.mp3
<canvas />
The <canvas /> element provides a context/stage in HTML for you to draw
shapes within. You will learn how to draw with the canvas JavaScript API in
Chapter 7.
The canvas API will give you an alternative to using DOM elements for graphic-
intensive animation or drawing. The <canvas /> element supports width and
height attributes. Any text within the <canvas /> element will be shown to
browsers that do not support it.
Listing 3-6 shows how to draw a simple semitransparent square using canvas.
Listing 3-6. Drawing a Simple Square in HTML5 Canvas
<canvas id="test-canvas" width="400" height="400">
<p>Your browser does not support HTML5 Canvas :(</p>
</canvas>
<script type="text/javascript">
var canvas = document.getElementById("test-canvas");
var context = canvas.getContext("2d");
context.fillStyle = "rgba(0, 0, 0, 0.5)"
context.fillRect(0, 0, 400, 400);
</script>
 
Search WWH ::




Custom Search