[whatwg] Serving up Theora <video> in the real world

Maciej Stachowiak mjs at apple.com
Thu Jul 9 20:04:42 PDT 2009


On Jul 9, 2009, at 7:46 PM, Gregory Maxwell wrote:

> On Thu, Jul 9, 2009 at 10:35 PM, Robert O'Callahan<robert at ocallahan.org 
> > wrote:
>> 2009/7/10 Ian Fette (イアンフェッティ) <ifette at google.com>
>>>
>>> To me, this seems like a great test if "canPlayType" actually  
>>> works in
>>> practice. In the perfect world, it would be great to do
>>> getElementById('video'), createElement, and
>>> then canPlayType('video/whatever','theora').
>>> If this simple use case doesn't work, I would ask if it's even worth
>>> keeping canPlayType in the spec.
>>
>> var v = document.getElementById("video");
>> if (v.canPlayType && v.canPlayType("video/ogg;  
>> codecs=vorbis,theora")) {
>>   ...
>> } else {
>>   ...
>> }
>>
>> should work great. Certainly does in Firefox.
>
> It works. Except where it doesn't. It's the "where it doesn't" that
> counts. At the moment Safari has issues. Out of two widely used
> production browsers with HTML5 support, one is broken. Not good odds,
> but I'm hopeful for the future.

Robert's code is a bit buggy; canPlayType returns a string, not a  
boolean, so it will always appear to say yes. Corrected sample code  
below. I tested, and the following is tragically broken in Safari  
4.0.2 even with XiphQT installed, but works as expected in WebKit  
nightlies and will very likely work in the next Safari dot release. In  
Safari 4.0.2 it will always say no, even with XiphQT installed. If you  
are patient, I would say just use this test and it will work as  
desired Real Soon. Please note, the 4.0.2 bug is just a bug, and not a  
design flaw in canPlayType.

<script>
var v = document.createElement("video");

if (v.canPlayType && v.canPlayType("video/ogg; codecs=vorbis,theora") ! 
= "no") {
     document.write("I CAN HAS OGG");
} else {
     document.write("OH NOES");
}
</script>


Regards,
Maciej




More information about the whatwg mailing list