View comments | RSS feed

Stream.setVirtualPath()

Availability

Flash Media Server 2.

Usage

myStream.setVirtualPath(virtualPath, directory, virtualKey)

Parameters

virtualPath A string indicating the virtual directory path of a stream. If the stream is not located in the virtual path, the default virtual directory path is searched.

strDirectory A string indicating the physical directory in which to store streams.

virtualKey A string that sets or removes the key value for each virtual path entry.

Returns

Nothing.

Description

Method; sets or removes the virtual directory path for video stream playback.

Flash Media Server can deliver two video codecs to clients: Sorenson Spark and the On2 VP6 codec. Flash Player 8 supports both codecs; Flash Player 7 and earlier supports only Sorenson Spark. You can use the Stream.setVirtualPath() method to dynamically serve Flash Player 8 clients a better version of a video stream.

When Flash Player requests a stream from Flash Media Server, the Flash Player version determines the server-side Client.virtualKey property (typically a mapping of the Flash Player version). Flash Media Server then serves the client a stream from whichever virtual directory the virtual key is mapped to. For example, if the client is Flash Player 8, the virtual key might map to the On2 streams directory, and the client would be served a higher quality stream. If the client is Flash Player 7, the virtual key might map to the default stream directory. This feature allows you to serve the same content to all clients in the optimum encoding for each client's platform.

The mapping between the virtual keys and virtual directories is made in the vhost.xml file. (For more information about the vhost.xml file, see "The Vhost.xml file" in Managing Flash Media Server). When you call setVirtualPath(), you are changing values in the VirtualDirectory tag of that file.

The following example shows the VirtualKeys section from the vhost.xml file in which the virtual keys can be mapped to a range of Flash Player versions:

<VirtualKeys>
    <Key from="WIN 7,0,19,0" to="WIN 9,0,0,0"></Key>
    <Key from="WIN 6,0,0,0" to="WIN 7,0,18,0"></Key>
    <Key from="MAC 6,0,0,0" to="MAC 7,0,55,0"></Key>
</VirtualKeys>

By default, there are no values in the key tags. To implement this feature, you must add the key values, either directly in the vhost.xml file, or with the setVirtualPath() method. For example, to implement this feature, set the first key to A, and the second two keys to B, as shown in the following example:

<VirtualKeys>
    <Key from="WIN 7,0,19,0" to="WIN 9,0,0,0">A</Key>
    <Key from="WIN 6,0,0,0" to="WIN 7,0,18,0">B</Key>
    <Key from="MAC 6,0,0,0" to="MAC 7,0,55,0">B</Key>
</VirtualKeys>

The following example shows what the VirtualDirectory section from the vhost.xml file could look like (the key values and Streams values are not in the file by default). The virtual keys are mapped to a virtual path and a physical directory, which are separated by a semi-colon (for example, foo;c:\streams). To set up several virtual directories for different Flash Player versions, use the same virtual path with different physical directories for each Streams tag, as shown in the following example:

<VirtualDirectory>
<!-- Specifies virtual directory mapping for recorded streams.   -->
<!-- To specify multiple virtual directory mappings for a stream,-->
<!-- add additional <Streams> tags; one for each virtual dir     -->
<!-- mapping. Syntax for virtual directories is as follows:      -->
<!-- <Streams>foo;c:\data</Streams>. This maps all streams whose -->
<!-- names begin with "foo/" to the physical directory c:\data.  -->
<!-- For example, the stream named "foo/bar" would map to the    -->
<!-- physical file "c:\data\bar.flv". Similarly, if you had a    --> 
<!-- stream named "foo/bar/x", then we first try to find a vdir  --> 
<!-- mapping for "foo/bar". Failing to do so, we then check for  -->
<!-- a vdir mapping for "foo". Since there is one, the stream    -->
<!-- "foo/bar" corresponds to the file "c:\data\bar\x.flv".      -->
    <Streams key="A">foo;c:\streams\on2</Streams>
    <Streams key="B">foo;c:\streams\sorenson</Streams>
    <Streams key="">foo;c:\streams</Streams>
</VirtualDirectory>

NOTE

 

You can also change the values of the VirtualKeys and VirtualDirectory tags directly in the vhost.xml file. This is the most common usage scenario. For more information about the vhost.xml file, see "The Vhost.xml file" in Managing Flash Media Server.

Example

The following code sets the virtual key to B, the virtual path to /foo, and the physical directory to c:\streams\on2:

myStream.setVirtualPath("B", "/foo", "c:\streams\on2");

Comments


No screen name said on Aug 1, 2007 at 7:55 AM :
Application Log in FMS2 says myStream.setVirtualPath() is not a function. Yes the Live Docs say its part of FMS2.
madovsky said on Oct 23, 2008 at 7:49 PM :
Be careful the example above shows the VirtualKey option in first so the right syntax is the virtualKey in last

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/fms/2/docs/00000792.html