jkythc
jkythc

Reputation: 430

Playing different type of video in different browser

I have three types of video namely .wmv, .avi and .mov

The following object code can work for IE and play the WMV file. But how can I play .avi in Chrome / Firefox, or play .mov in Safari/Opera?

<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" id="player" width="100%" height="600">
<param name="url" value="file.wmv" />
<param name="src" value="file.wmv" />
<param name="showcontrols" value="true" />
<param name="autostart" value="false" />
<!--[if !IE]>-->
<object type="application/x-oleobject" data="file.avi" width="100%" height="600">
<param name="src" value="file.avi" />
<param name="autostart" value="false" />
<param name="controller" value="true" />
</object>
<!--<![endif]-->
</object>

17:12 p.m.---- I have modified the code using HTML5 coding, it is worked for Chrome to play .mov file now, but still can't play the video in Firefox / Safari / Opera.

<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" id="player" width="100%" height="600">
<param name="url" value="file.wmv" />
<param name="src" value="file.wmv" />
<param name="showcontrols" value="true" />
<param name="autostart" value="false" />
<!--[if !IE]>-->
<video width="100%" height="600" preload controls>
<source src="file.avi" />
<source src="file.mov" />
<source src="file.wmv" />
</video>
<!--<![endif]-->
</object>

Upvotes: 0

Views: 381

Answers (3)

Stefan Lederer
Stefan Lederer

Reputation: 453

You can also go for an adaptive streaming format like MPEG-DASH or HLS. E.g. the bitdash player plays MPEG-DASH content across all browsers, either by using the HTML5 MSE or using MPEG-DASH playback in Flash.

Upvotes: 0

Mick
Mick

Reputation: 25481

Take a look at this link for a good overview of an approach that gives as much coverage as possible with the minimum number of video formats:

Update and background

As Nisse points out below, it would generally be nicer to provide some examples of the current best practice here. The problem is that the domain changes so fast that I find that a small number of sites which provide a good up to date overview are invaluable to look at to get the current status.

The reason there is so much change is due to several factors:

Multiple Video Codecs

Codecs encode the 'raw' video into a format which is generally smaller so easier to store and transmit. Why are there so manny different video formats? Some exist because better compression techniques have been developed requiring a new format, and some exist because people find some existing good formats too licence or patent encumbered. Some probably exist simply because different companies or standards bodies generated similar standards in parallel.

Multiple streaming 'containers'

Containers 'package' or wrap one or more audio and video streams and provide a means to stream them as a combined entity from one place to another (e.g. server to client). To allow for different bit rates for different network conditions many now support adaptive bit rate technologies - basically they provide multiple video streams in different bit rates on the server and the client can switch between them depending on network congestion. The main existing ABR formats are associated with particular companies - HLS for apple, Smooth Streaming for Microsoft and Adaptive Streaming for Adobe. There is also an emerging open industry standard, MPEG DASH. As with your different video formats, different browsers and devices and even Javascript players within devices support different ABR protocols and this also is changing rapidly at the moment. DASH and the associated open DRM approach, CENC, use the HTML5 MSE and EME extensions (Media Source Extensions and Encrypted Media extension).

Multiple fast evolving clients

Both Mobile devices and Web Browsers evolve at an (alarming...) rate these days - many browsers are set to auto update and the replacement rate of mobile devices means new ones are coming on stream every day. At the same time there is a percentage or users who continue with older devices and still want to be able to play your videos. Newer devices, browser and media players tend to support the newer specifications, unsurprisingly, but unfortunately, they also sometimes drop support for the older ones - generally for sensible reasons, as maintaining support for multiple formats is too much work.

So...

What this all means for you is that to play your content on as many different devices as possible, at this time you need to have multiple different versions of your video. Ideally, you will not just have different encodings and file types, but also different bit rate versions of each to support adaptive bit rate steaming.

As you can see this is very hard to keep on top of unless you specialise in this area - this is why I find that using some of the better supported sites to check the current status at any given time is a good approach.

The site listed above is useful as it not only gives a summary of the current position but also provides suggested script which is generally kept up to date to match the latest browser etc releases.

Some other sites I find useful in addition to the one above:

Upvotes: 1

1&#39;&#39;
1&#39;&#39;

Reputation: 324

Check for the user-agent in php or javascript and adjust the video accordingly.

In javascript:

var x = "User-agent header sent: " + navigator.userAgent;

Then pick out the browser used.

In PHP:

<?php  echo $_SERVER['HTTP_USER_AGENT']; ?>

You adjust the video file based off what either of these return.

Upvotes: 0

Related Questions