html5 and css3

25
HTML5 AND CSS3 Neal Stublen [email protected]

Upload: menora

Post on 24-Feb-2016

44 views

Category:

Documents


0 download

DESCRIPTION

Neal Stublen [email protected]. HTML5 and CSS3. Chapter 5 Audio and Video. Pre-HTML5 Solutions. Audio and video were embedded in pages using plug-ins Apple Quicktime Microsoft Silverlight Adobe Flash. Native Audio and Video. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: HTML5 and CSS3

HTML5 AND CSS3Neal Stublen

[email protected]

Page 2: HTML5 and CSS3

CHAPTER 5

AUDIO AND VIDEO

Page 3: HTML5 and CSS3

Pre-HTML5 Solutions Audio and video were embedded in

pages using plug-insApple QuicktimeMicrosoft SilverlightAdobe Flash

Page 4: HTML5 and CSS3

Native Audio and Video HTML5 provides audio and video

elements for built-in media supportNot supported pre-IE9

AudioRoughly 85% support

VideoRoughly 85% support

Page 5: HTML5 and CSS3

Video Container Format Containers are specific file formats for

transporting audio and videoWraps a video track, audio track, and data

to synchronize the tracksLanguage informationMedia metadata

Containers for HTML5 include MPEG-4, Ogg, WebM

Page 6: HTML5 and CSS3

Audio and Video Codecs Codecs define algorithms used to

encode or decode a media streamCoder/decoder

Video codecs relevant to HTML5 include H.264, Theora, and VP8

Audio codecs relevant to HTML5 include AAC and Vorbis

Page 7: HTML5 and CSS3

Browser Support Audio and video streaming requires

browser support for the container and codecs used for a specific media stream

Audio and video tags provide a standard way of incorporating media on a web page, but the browser/OS still need to support chosen data formats

http://caniuse.com details support

Page 8: HTML5 and CSS3

Including Video Basic tag use: <video src=“example.webm”></video>

Typical tag use: <video src=“example.webm” width=“800” height=“480” controls></video>

Page 9: HTML5 and CSS3

Built-in Controls The controls attribute specifies that the

browser should display built-in controls for controlling playback

Controls are browser-specificNo standard appearanceStandard appearance would require use of

additional markup and JavaScript

Page 10: HTML5 and CSS3

The autoplay attribute Media will not begin playing

automatically The autoplay attribute will start playback

after the page has loaded

<video src=“example.webm” autoplay></video>

Page 11: HTML5 and CSS3

The loop attribute Seeks back to the start of the media

after reaching the end Most likely use may be background

sounds or music (perhaps in a game)

<video src=“example.webm” loop></video>

Page 12: HTML5 and CSS3

The preload attribute preload=“auto”

Begins loading the media stream before the user presses the play button

Faster response preload=“none”

Prevents loading the video before pressing playLess bandwidth

preload=“metadata”Loads media metadata (duration, dimensions)

Browsers determine the default value

Page 13: HTML5 and CSS3

The poster attribute Specifies an image that should appear

as the “teaser” for a video elementposter=“teaser.png”

Page 14: HTML5 and CSS3

The audio attribute Allows the audio track to be muted by

defaultaudio=“muted”

Page 15: HTML5 and CSS3

Handling Supported Formats Provide source elements instead of a src

attribute

<video controls> <source src=“example.mp4” type=“video/mp4” /> <source src=“example.webm” type=“video/webm” /> </video>

Page 16: HTML5 and CSS3

Specifying Codecs<source src=“example.mp4” type=‘video/mp4; codecs=“avc1.42E01E, mp4a.40.2” /><source src=“example.webm” type=‘video/webm; codecs=“vp8, vorbis” />

Page 17: HTML5 and CSS3

source Order Browsers will use the first compatible

source element even if they support multiple available formats

Page 18: HTML5 and CSS3

Fallback Support Browsers that don’t support the audio and

video tags will simply render the content within the tags

An object tag can be used to embed support for older methods, such as Flash

Modern browsers will ignore the additional content within the tag that’s not a source element

Fallback support could be a download link

Page 19: HTML5 and CSS3

MIME Types The type attribute specifies the MIME

type for the mediaMultipurpose Internet Mail Extensions

Your web server may need to be properly configured to serve specific MIME types correctly

Page 20: HTML5 and CSS3

Video Encoding If you have video that is not in a

supported format, it will need to be encoded againMiro Video Converter

You should be able to encode a single source into the multiple formats that cover most browsers

Page 21: HTML5 and CSS3

Custom Controls Audio and video tags can be accessed

from JavaScript just like any other elements

Additional markup can be used to create your own controls

Page 22: HTML5 and CSS3

Audio and Video Events canplay – indicates playback can begin error loadeddata loadedmetadata playing – also indicates looping seeking seeked

Page 23: HTML5 and CSS3

Audio and Video Attributes playbackRate src (from attribute) currentSrc (from attribute or element) readyState duration buffered videoWidth/videoHeight (source sizes)

Page 24: HTML5 and CSS3

Audio Differences Invisible unless controls are specified Allows possibility of using multiple audio

elements for background sounds MP3 and Ogg/Vorbis formats will cover

all major browsers

Page 25: HTML5 and CSS3

Text Tracks Including track elements within a video

element allows inclusion of subtitles, captions

<track kind=“subtitle” src=“subtitles.en.vtt” srclang=“en” label=“English” />