Creating clients for streaming services



Using the sample video player

The Flash Media Server Start Screen includes an embedded video player. The video player lets you see video streaming from the server immediately after installation. Use the code provided on the Start Screen to embed the video player in your own application.

You can examine the video player at RootInstall/samples/videoplayer and modify it as desired.

Using the Flash FLVPlayback component

You can use the FLVPlayback component, available since Flash 8, as a client for the vod and live services. Set the source parameter (or contentPath parameter in ActionScript 2.0) to the full URL of the stream. To connect to the live service, set the isLive parameter to true. You can set parameters in the Component inspector or in ActionScript.

Set the source (or contentPath) parameter to the URL of the stream. Do not include the /media folder in the path. For example, the following is the path to a sample file: rtmp://localhost/vod/sample.flv.

Using the Flex VideoDisplay component

You can use the Flex VideoDisplay control to play an FLV or F4V file in a Flex application. The component supports progressive download over HTTP, streaming from Flash Media Server, and streaming from a Camera object. Set the source parameter to the full URL of the stream. Do not include the /media folder in the path. For example, the following is the path to a sample file: rtmp://localhost/vod/sample. To stream live video, set the live parameter to true.

Connecting to a streaming service

Like all Flash Media Server applications, streaming services expect the NetConnection.connect() URI to be in the following format:

rtmp://hostName/serviceName/[formatType:][instanceName/]fileOrStreamName
hostName
The Flash Media Server domain name.

serviceName
Either live or vod.

instanceName
If the client is connecting to the default instance, you can either omit the instance name or use _definst_. If the client is connecting to an instance you have created, such as room1, use that name.

formatType
For mp3 files, mp3:. For MP4/F4V files, mp4:. Not required for FLV files.

fileOrStreamName
Either a filename (for example, my_video.mp4) or a path (for example, subdir/subdir2/my_video.mp4), for example, rtmp://www.examplemediaserver.com/vod/mp4:ClassicFilms/AnOldMovie.mp4. For MPEG-4-based files, if the file on the server uses a filename extension (.mp4, .f4v, and so on), specify it. If the stream is live and the publisher specified a filename extension, specify it.

Unsupported features

Clients for the vod and live services can use any Flash Player features except remote shared objects (SharedObject.getRemote()).

You cannot edit the server-side code for streaming services. However, the services do have a custom API that lets you access information from the server. Call the NetConnection.call() method from client-side code and pass it the name of the API you want to call. For more information, see Streaming services API.

Allow connections from specific domains

By default, clients can connect to the live and vod services from any domain. You can limit the domains from which clients can connect.

 Navigate to the RootInstall/applications/live or RootInstall/applications/vod folder and do one of the following:
  • To add a domain for SWF clients, edit the allowedSWFdomains.txt file.

  • To add a domain for HTML clients, edit the allowedHTMLdomains.txt file.

The TXT files contain detailed information about adding domains.

Access raw audio and video data in the live service

Note: Flash Media Streaming Server does not support this feature.

Beginning with Flash Media Server 3 and Flash Player 9.0.115.0, you can access raw audio and video data in live streams. Use this data to create snapshots in your applications. To access the data, call the ActionScript 3.0 BitmapData.draw() and SoundMixer.computeSpectrum() methods. For more information, see ActionScript 3.0 Language and Components Reference at www.adobe.com/go/learn_fms_asdoc3_en.

By default, Flash Media Server prevents you from accessing streams. To allow stream access, do the following:

  1. Move the main.far file from RootInstall/applications/live to RootInstall/samples/applications/live.

    You cannot edit FAR files, so you must replace main.far with main.asc.

  2. Copy the main.asc file from RootInstall/samples/applications/live to RootInstall/applications/live.

  3. Open the main.asc file in a text editor.

  4. Uncomment the following code to allow all clients to access all streams:

    //p_client.audioSampleAccess = "/"; 
    //p_client.videoSampleAccess = "/";
  5. Save the main.asc file.