/

HTML / CSS / JavaScript Tutorial

JavaScript media object method: canPlayType()

[this page | pdf | back links]

The canPlayType() method of the JavaScript DOM object corresponding to HTML media  elements (i.e. <audio> and <video> elements) indicates if browser can play the media type.

 

It has the following syntax with the following parameters. It returns a string indicating likely level of support. Possible return values include: “probably” (most likely to support), “maybe” (might support) or “” (empty string, no support)

 

object.canPlayType(type)

 

Parameter

Required / Optional

Description

type

Required

Type (and optional codecs) to test support for, e.g. audio/mp4; codecs="mp4a40.5" or video/ogg

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile