Home > Web Front-end > H5 Tutorial > body text

The method canPlayType() in HTML5 determines whether the browser can play the specified audio/video type.

黄舟
Release: 2017-11-07 11:21:24
Original
2556 people have browsed it

Example

Detect whether your browser can play different types of videos:

myVid=document.createElement('video');
isSupp=myVid.canPlayType(vidType+';codecs="'+codType+'"');
Copy after login

Definition and usage

canPlayType() method browsing Whether the device can play the specified audio/video type.

The canPlayType() method can return one of the following values:

  • "probably" - The browser is most likely to support this audio/video type

  • "maybe" - The browser may support this audio/video type

  • "" - (empty string) The browser does not support this audio /Video Type

Browser support

All browsers support the canPlayType() method.

Note: This method is not supported in Internet Explorer 8 and earlier.

Syntax

audio|video.canPlayType(type))
Copy after login

Parameters

Return value
Value Description
type

specifies the audio/video type to be detected.

Common values:

  • video/ogg

  • ##video/mp4

  • video/webm

  • audio/mpeg

  • audio/ogg

  • ##audio/mp4
  • Common values, including codecs:

    video/ogg; codecs="theora, vorbis"
  • video/mp4; codecs="avc1.4D401E, mp4a.40.2"
  • video/webm; codecs="vp8.0, vorbis"
  • audio/ogg; codecs="vorbis"
  • ##audio/mp4; codecs="mp4a.40.5"
  • Note: Only "probably" can be returned if the codec is included.

TypeDescriptionString
indicates the supported level. Possible values:

"probably" - most likely supported
  • "maybe" - probably supported
  • "" - (empty string)
is not supported

The above is the detailed content of The method canPlayType() in HTML5 determines whether the browser can play the specified audio/video type.. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template