I know there are numerous web sites and blogs about this subject. Since I had to write some code for "Fred" to render on-line video, and embedding video in web pages can be somewhat fiddly to get right, I figured I'd blog the C# code for my future reference. If hosting on-line video in your web site interests you, be sure to check out Sahil Malik's
post on the subject.
Below are two examples, which create the HTML for embedding Windows Media and Quicktime sources. To use this code, compile either or both examples into your ASP.NET project (or into a referenced class library assembly), bung a
PlaceHolder on your page and during the load event of your page pass the instance of your PlaceHolder control to the desired method. The location should either be a relative URL or absolute URL to the hosted video file, which can be a streaming location or an HTTP location.
Embedding Windows Media:
Embedding Quicktime:
That's it.... now if you're really good, you can detect the client operating system, by looking for the word "Windows" in the user agent string (hint:Request.UserAgent) and calling the correct method above.
I tested the above code using FireFox and IE (Windows and Mac). Windows Media will play in FireFox if you have the Windows Media Plugin (Windows version ships with latest version of
Windows Media Player) installed, and the rendering
Quicktime requires the plugin from Apple (duh).