How To Embed a Swooshed Media Player

One great thing about swooshed links is they behave just like regular links, and thus can be put anywhere a regular link goes -- such as into an embedded video player. To put an embedded video player on your website (whether or not it's powered by a swooshed link), follow along.

Step 1: Embed the original, unswooshed link

The first thing to do is to embed the video player itself into your page. To get started, just embed the original, unswooshed link (and thus make sure everything is working before bringing Red Swoosh into the equation). Though there are as many ways to do it as browsers in the sky, the best way we could figure out to do it follows:

<OBJECT width="320" height="287" id="MediaPlayer"
        classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
        codebase=
"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab##Version=6,4,5,715"
        standby="Loading Microsoft Windows Media Player components..."
        type="application/x-oleobject">
<PARAM value="http://www.redswoosh.net/media/video/test.wmv" name="FileName"/>
<EMBED width="320" height="287"
       src="http://www.redswoosh.net/media/video/test.wmv"
       name="MediaPlayer" type="application/x-mplayer2"
       pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"/>
</OBJECT>

Step 2: Swoosh the link

Next just take the original link (in this case our trusty, somewhat dusty test video http://www.redswoosh.net/media/video/test.wmv), and stick http://edn.redswoosh.net in front of it. Tah-dah! It's swooshed. The result looks like this:

Step 3: Click the swooshed link

Click it. Come on, you know you want to. If you aren't already installed, you'll be prompted to do so now. Otherwise, when you click the link it should behave exactly like when you click on the original, unswooshed link above. Indeed, for a fun test, right-click on the properties of the video as it's playing and verify it's coming from http://127.0.0.1:9421 -- a clear sign that something magic is going on, and that magic is Red Swoosh.

Step 4: Embed the swooshed link

Now, to bring it all together, use the same embedded video code we have above, but replace the link with its swooshed equivalent. As you'll no doubt discover, it continues to work, just like before. But unlike before, the video is downloaded and streamed in realtime from peers -- taking the load of your servers. How's that for a neat trick?

Note: Now there is one picky detail that needs attending to. A normal swooshed link is just http://edn.redswoosh.net stuck in front of another http://whatever/blah.wmv link. But sometimes having two "http://" strings in a single URL freaks some programs out. Unfortunately, Windows Media Player is one of those. But not to worry -- the second "http://" is entirely optional for just this reason. Thus when embedding a swooshed link, be sure to take out the second "http://" and just make the link as follows: http://edn.redswoosh.net/www.redswoosh.net/media/video/test.wmv

Note: For this example to work, you need to have already installed Red Swoosh. To do this, just click on the swooshed link in step 3 and follow the on-screen instrutions.

<OBJECT width="320" height="287" id="MediaPlayer2"
        classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
        codebase=
"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab##Version=6,4,5,715"
        standby="Loading Microsoft Windows Media Player components..."
        type="application/x-oleobject">
<PARAM value="http://edn.redswoosh.net/www.redswoosh.net/media/video/test.wmv" name="FileName"/>
<EMBED width="320" height="287"
       src="http://edn.redswoosh.net/www.redswoosh.net/media/video/test.wmv"
       name="MediaPlayer2" type="application/x-mplayer2"
       pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"/>
</OBJECT>

Step 5: Reading the file straight from disk

But wait, there's more! You might have noticed in step 3 that the content is actually being downloaded from 127.0.0.1 (aka "localhost") rather than from the webserver. The details of why this is the case are so incredibly exciting that I won't bother you with them here. But you should know that because of this, Windows Media Player tends to think the file is coming from over the internet, even when in fact it's already been downloaded to your computer. (Remember how I said "it behaves exactly like a normal link?") What this means to you is that the video can take a moment to start playing, because it's "prebuffering" the file on the assumption that the network might hiccup -- a common occurance on the internet but unlikely when reading straight from disk.

To eliminate this slight delay and provide an experience that's even more instant, check out the 'rs_localURL' attribute of the JavaScript API. The specifics of this are outside the scope of this tutorial, but the basic process includes:

  1. Call redswooshInitialize until you've verified that the client is running
  2. Call redswooshDownloadFile to begin downloading the file (if it hasn't been already)
  3. Call redswooshUpdateAttributes to get a list of files downloading in the rs_fileAttributes global variable
  4. Wait until rs_fileAttributes['http://www.redswoosh.net/media/video/test.wmv']['rs_status'] equals 'COMPLETE', indicating that the file has completed downloading (else you'll begin playing a file from disk before it's been fully downloaded, and all sorts of bad things will happen).
  5. Create an embedded player using the direct on-disk path, listed in rs_fileAttributes['http://www.redswoosh.net/media/video/test.wmv']['rs_localURL']

With this technique, the player will open the file and read straight from disk, bypassing the internal prebuffering algorithms and providing an instant playback experience. This is particularly valuable when combined with predelivered files, as you can do instant playback of enormous files at higher bitrates than can be streamed over the user's connection.

This page has been viewed times.


Page Information

  • 2 years ago [history]
  • View page source
  • You're not logged in
  • Recent comments:
    redqc:redswoosh links do not work on vlc newest plugin :(
    redqc:just to mention, using swooshed links to embed will only work on Microsoft Windows Media Player , Divx Web Player. vlc embeded plugin. im not sure if there are others but these the main 3 it works with. also like to mention that other media players. seem to not understand how to follow up the swooshed link format , other media players having problems understanding how requests work on redswoosh etc. thats my thoughts example, ALshow media player doesnt understand how to stream video from the swoosh network. so is GOM Media player. and many others.
  • No tags yet learn more

Wiki Information


Update to PBwiki 2.0

An entirely new PBwiki experience, including folders and easier editing.

Convert Now for Free | Learn more