Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML Video (Video) Playback

HTML Video (Video)


There are many ways to play video in HTML.


HTML Video (Videos) Playback

Example

<

video

width

=

"

320

"

height

=

"

240

"

controls

<

source

src

=

"

movie.mp4

"

type

=

"

video/mp4

"

<

source

src

=

"

movie.ogg

"

type

=

"

video/ogg

"

<

source

src

=

"

movie.webm

"

type

=

"

video/webm

"

<

object

data

=

"

movie.mp4

"

width

=

"

320

"

height

=

"

240

"

<

embed

src

=

"

movie.swf

"

width

=

"

320

"

height

=

"

240

"

object

video

Try it »


Problems and Solutions

Playing video in HTML is not easy!

You need to master a number of techniques to ensure that your video files can play in all browsers (Internet Explorer, Chrome, Firefox, Safari, Opera) and on all hardware (PC, Mac, iPad, iPhone).

In this chapter, Runoob Tutorial summarizes the problems and solutions for you.


Use tag

The tag is used to embed multimedia elements in an HTML page.

The following HTML code shows a Flash video embedded in a web page:

Example

Try it »

Problem


Use tag

The tag is used to embed multimedia elements in an HTML page.

The following HTML snippet shows a Flash video embedded in a web page:

Example

Try it »

Problem:

  • If the browser does not support Flash, the video will not play.
  • iPad and iPhone cannot display Flash videos.
  • If you convert the video to other formats, it still cannot play in all browsers.

Using HTML5

HTML5

The following HTML snippet displays a video in ogg, mp4, or webm format embedded in a web page:

Example

Try it »

Problem:

  • You must convert the video into many different formats.

The Best HTML Solution

The following example uses 4 different video formats. HTML5

HTML 5 + +

Try it »

Problem:

  • You must convert the video into many different formats

Using Hyperlinks

If a web page contains a hyperlink to a media file, most browsers will use a "helper application" to play the file.

The following code snippet shows a link to an AVI file. If the user clicks the link, the browser will launch a "helper application", such as Windows Media Player, to play the AVI file:

Example

Play a video file

Try it »


Notes on Inline Video

When a video is included in a web page, it is called an inline video.

If you plan to use inline video in a web application, you need to be aware that many people find inline video annoying.

Also note that users may have turned off the inline video option in their browser.

Our best advice is to include inline videos only where users expect to see them. A positive example is when a user needs to see a video and clicks a link, which opens the page and then plays the video.


HTML Multimedia Tags

New : HTML5 new tag.

tag Description
Defines an embedded object. Deprecated in HTML4, allowed in HTML5.
Defines an embedded object.
Defines a parameter for an object.
New Defines sound content
New Defines a video or movie
New Defines multimedia resources for the media element (
New Specifies subtitle files or other text-containing files for the media element (