Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. HTMLMediaElement
  4. canPlayType()

HTMLMediaElement: canPlayType() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

TheHTMLMediaElement methodcanPlayType() reports how likely it is that the current browser will be able to play media of a givenMIME type.

Syntax

js
canPlayType(type)

Parameters

type

A string specifying theMIME type of the media and (optionally) acodecs parameter containing a comma-separated list of the supported codecs.

Return value

A string indicating how likely it is that the media can be played.The string will be one of the following values:

"" (empty string)

The media cannot be played on the current device.

probably

The media is probably playable on this device.

maybe

There is not enough information to determine whether the media can play (until playback is actually attempted).

Examples

js
let obj = document.createElement("video");console.log(obj.canPlayType("video/mp4")); // "maybe"

Specifications

Specification
HTML
# dom-navigator-canplaytype-dev

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp