Flash Media Server Developer Documentation

Stream.setVirtualPath()

myStream.setVirtualPath(virtualPath, directory, virtualKey)

Sets the virtual directory path for video stream playback. Maps a virtual directory path to a physical directory and assigns that mapping to a virtual key. The virtual key designates a range of Flash Player versions. These mappings let you use the same URL to serve different versions of streams to clients based on the Flash Player version.

First, create a mapping between Flash Player versions and virtual keys in the VirtualKeys section of the Vhost.xml file. When Flash Player requests a stream from Flash Media Interactive Server, the Flash Player version is mapped to a virtual key based on the values that you set in the Vhost.xml file, as in this example:

<VirtualKeys>
    <!-- Create your own ranges and key values.    -->
    <!-- You can create as many Key elements as you need.    -->
    <Key from="WIN 8,0,0,0" to="WIN 9,0,59,0">A</Key>
    <Key from="WIN 6,0,0,0" to="WIN 7,0,55,0">B</Key>
</VirtualKeys>

Next, in the VirtualDirectory section of the Vhost.xml file, map the virtual keys to a virtual path and a physical directory, which are separated by a semicolon (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 this example:

<VirtualDirectory>
    <Streams key="A">foo;c:\streams\on2</Streams>
    <Streams key="B">foo;c:\streams\sorenson</Streams>
</VirtualDirectory>

Flash Media Interactive Server serves the client a stream from whichever virtual directory the virtual key is mapped to. For example, if the client is Flash Player 8 and the call is myNetStream.play("foo/familyVideo"), the Streams element with key A would be used and the client would be served the higher-quality stream c:\streams\on2\familyVideo.flv. If the client is Flash Player 7, the same URL maps to the sorenson stream directory and the c:\streams\sorenson\familyVideo.flv file plays.

It is most common to change the values of the VirtualKeys and VirtualDirectory elements in the Vhost.xml file. However, you can call Stream.setVirtualPath() to create Streams elements and you can use Client.virtualKey to set a client's Key value.

For more information about the Vhost.xml file, see Adobe Flash Media Server Configuration and Administration Guide.

Availability

Flash Media Server 2

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.

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

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

Note: To indicate a slash in the virtualPath and directory parameters, you must use a forward slash (/) or a double backslash (\\). In strings, single backslashes are used to escape characters. A double backslash is the escape sequence for a backslash character.

Example

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

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