7

I want embed a video in a webpage.
I don't want to use flash because it's unavailable for a huge number of platforms.
I'm reluctant to use HTML5 becase it's not too standard yet (It IS standard, but most people don't have browsers that support it)

Is there any other way? Or should I stick to HTML5 and a HUGE banner telling people to upgrade their browser?

Esteban Küber
  • 36,388
  • 15
  • 79
  • 97
WhyNotHugo
  • 9,423
  • 6
  • 62
  • 70
  • 2
    Hugo, I removed your "personal" opinion on Flash from your question. You'll just get flamed and then your question would be closed as "subjective and argumentative" – Binary Worrier Jul 29 '09 at 14:38
  • 1
    The point was not to criticize it, but rather to say "I don't WANT to use it". :) – WhyNotHugo Jul 29 '09 at 14:57
  • I feel the same and it tooks me some years to find a solution... Here it is! It's not the best solution ever... Performance is not really good... But it works! (Just posted it here as an answer) – Charles-Édouard Coste Nov 08 '14 at 21:49

6 Answers6

8

There are a few ways to combine HTML5 video with fallbacks for non-supporting browsers. A few specific solutions have been demonstrated.

One example is Video for Everybody by Camen Design, which conforms to HTML5, and uses conditional comments for IE and a nested object tag for older browsers. This should be standards-compliant, backwards-compatible, and future proof.

Michael Zajac
  • 156
  • 1
  • 3
6

HTML 5 is not standard. It is a draft. It will probably become standard one day. It will probably change first.

If you want to embed video in a page then, today at least, Flash is the best supported option you have available. I'd provide a link to a regular downloadable version as an option for people who don't have Flash (or who just want to watch the video in a dedicated video player).

Telling people to upgrade their browser won't help a great deal. As far as I know, the only browser with video support in a stable release is Firefox. Chrome doesn't support it except in the development version. I don't think Opera has brought out a stable build with support. Microsoft certainly hasn't added it to Internet Explorer yet. Safari I'm not sure about.

If you really want to avoid Flash, then you could use an HTML 4.01 object.

<object data="myVideo.ogv" type="video/ogg">
  <!-- fallback content here -->
</object>

… and hope the user has a plug-in capable of handling the video installed.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • I've never come across this. What plays the video in this tag? Do mayor browsers actually have a plug-in that makes this work, or is this a 5%-of-the-people thing? – WhyNotHugo Jul 29 '09 at 14:53
  • It is standard HTML 4.01. Whatever plug-in registers itself to handle video/ogg (in this example) data handles it. Installing VLC gave me the support I needed for that (and Firefox prompted me to look for a plugin when it wasn't installed). I've never investigated the install base of suitable plug-ins so I don't know what the support level is like out in the wild. – Quentin Jul 29 '09 at 15:05
  • Cool. It's a pretty good fallback for the – WhyNotHugo Jul 29 '09 at 22:59
  • @Wahnfrieden Hi! Welcome to the 2009. Things might be a little different from what you are used to. http://www.w3.org/TR/html5/video.html#video – Quentin Aug 06 '09 at 15:04
  • @David Dorward, no need to be sarcastic. I'm mistaken - the – aehlke Aug 07 '09 at 16:30
  • It does offer a clear advantage over - a consistent API and a means to test if the video format is supported. Codecs will almost certainly standardise quickly anyway. – Quentin Aug 07 '09 at 21:51
  • 1
    @David two years later, and the battle still rages. I wish you'd been right :( – Matthew Scharley May 12 '11 at 04:52
2

I've just come across Cortado. It's a Java applet that plays an OGG. I actualy have to thank David Dorward for this, since checking up HTML5's status made me come across it. Firefox suggests using something like:

 <video src="my_ogg_video.ogg" controls width="320" height="240">  
   <object type="application/x-java-applet"  
           width="320" height="240">  
      <param name="archive" value="cortado.jar">  
      <param name="code" value="com.fluendo.player.Cortado.class">  
      <param name="url" value="my_ogg_video.ogg">  
      <p>You need to install Java to play this file.</p>  
   </object>  
 </video>  

Java is available to FAR MORE platforms than flash, and, in this case, if just a fallback to HTML5.

(source)

WhyNotHugo
  • 9,423
  • 6
  • 62
  • 70
1

I know it's a bit late, but did you have a look at VLC ?

It can be embedded in a website, runs on Windows, Mac OS & Linux, is free, open source, supports a lot of video/audio format...

The drawback is that it doesn't have a nice GUI with play/pause/set volume/ ... functions , you have to create them yourself.

You can have a look at this article: http://www.videolan.org/doc/play-howto/en/ch04.html#id310965

chrisnfoneur
  • 401
  • 1
  • 5
  • 11
  • Thanks, I actually came across this the other day. I ended up using HTML5 with java fallback, but this isn't a very bad idea either. Only problem would be clients without VLC installed. – WhyNotHugo Jan 01 '10 at 06:55
0

Why do you think a lot of large websites use Flash to play video? Probably not because of it's unavailability... Of course there are alternatives to embed video content in a web page, but if availability is an issue, Flash is the best way to go at the moment.

Daan
  • 6,952
  • 4
  • 29
  • 36
  • Lets just assume flash isn't an option for Hugo. What should he use? – Binary Worrier Jul 29 '09 at 14:40
  • Even if it's only 10% of the people that are left out, I want to avoid it. I have some other reasons to hate flash anyway, so I just won't use it. – WhyNotHugo Jul 29 '09 at 14:44
  • It is probably more like 0.1% of people. – Quentin Jul 29 '09 at 14:46
  • @BW: What he should use depends on the goal / target users of the website. The general public: use a format for which *most* users have a plug-in (not sure which that would be). Specific user group / company / technical environment: use the format that is available in that context. – Daan Jul 29 '09 at 14:50
  • Probably. Even x86 linux users aren't excluded in this case. – WhyNotHugo Jul 29 '09 at 14:51
  • I want as much people as possible to be able to view this. Personally, I use an OS with no flash support, and where gnash has dropped development as well, so no chance. That fact aside, flash usually "breaks consistency" in many browsers. Browser hotkeys are unusable as flash has focus; doesn't respect accessibility (font size) settings, etc. – WhyNotHugo Jul 29 '09 at 14:56
  • @Hugo: all very true, and these are indeed shortcomings of Flash, but if Flash can make the difference between your content being available to a lot of people or not (provided that's the intention of course), it might be worth putting up with all that. – Daan Jul 29 '09 at 14:58
  • I don't think that you're going to find any in-browser video solution that has a wider availability than Flash at this time. – aehlke Aug 06 '09 at 14:50
0

I worked on this problem as I'm very interested in xHtml+RDFa and I found a way to play a video in an xHtml 1.0 strict document on HTML5 browsers without blocking not HTML5 browsers.

I published a jQuery plugin here: https://github.com/charlycoste/xhtml-video

And a demo here: http://demo.ccoste.fr/video

Actually, this is quite less powerfull than using a HTML5 tag, but at least... it works!

The solution relies on javascript and canvas but can be gracefully degraded by using <object> tags (that's what my jQuery plugin does).

What I do is actually simple:

  1. I create a new video element (not a tag) in memory but I don't add it to the DOM document:

    var video = document.createElement('video');
    
  2. I create a new canvas element in memory but I don't add it to the DOM document:

    var canvas = document.createElement('canvas');
    
  3. I create a new img element and I add it to the DOM.

    // var parent = ... ;
    // var width = ...;
    // var height = ...;
    var img = document.createElement('img');
    
    img.setAttribute('width', width);
    img.setAttribute('height', height);
    
    parent.appendChild(img);
    
  4. When video is playing (video.play()), I make it draw each frame in the canvas (which is not visible, because not added to the DOM - which makes the DOM stay valid xhtml 1.0 document)

    canvas.getContext("2d").drawImage(video, 0, 0, width, height);
    
  5. Finally I use the toDataURL() method of the canvas element to get a base64 encoded image for the frame and put it to the src attribute of the img element.

    img.setAttribute('src', canvas.toDataURL());
    

By doing this, you make javascript objects play a video out of the DOM and push each frame in an img DOM element. So you can play the video by using HTML5 capabilities of the browser, but with no need of a HTML5 document.

And if the browser has no HTML5 capabilities or if it can't handle the used codec, it will fall back on the native <object> behaviour (in general... the browser will look for a plugin like VLC, or so on...)

And if there is no way for playing the video (no plugin for it), the alternative content provided inside the <object> tag will be used.

Performance aspect: as it results in a very high consuming process, the playback may flicker... To avoid this, you can decrease rendering quality by using jpeg compression this way : canvas.toDataURL('image/jpeg', quality) where quality is a value between 0 and 1.