Accessibility

Table of Contents

Understanding live DVR – Part 1: Implementing a live DVR player

Walkthrough 1: Enabling DVR on a live stream

In this walkthrough you will:

  • Implement a DVR-enabled publisher for broadcasting video (see Figure 2)
  • Publish video from the publisher component and a web cam

Completed DVR-enabled video publisher

Figure 2. Completed DVR-enabled video publisher

  1. Create a new, empty, dvr directory in the {Flash Media Server Install}/applications/ directory.
  2. Open the file DVR-FlashConsumerPublisher.fla in the {start files}/hands-on/DVR-Publishing/start/ directory.
  3. Set the Document class property to the following (see Figure 3):

    com.realeyes.dvr.FlashConsumerPublisher

    Setting the Document class property

    Figure 3. Setting the Document class property

  4. Open the FlashConsumerPublisher class in the {start files}/hands-on/DVR-Publishing/start /com/realeyes/dvr/ directory. The FlashConsumerPublisher class manages the connection and passes the NetConnection and stream name to the VideoConsumer and VideoPublisher classes (you will work with these later), so the connection is shared between the two.
  5. In the FlashConsumerPublisher class, locate the following comment:

    // Declare connection path and video ID
  6. Declare a public String property named connURI and set it equal to the rtmp:// path to the dvr application on your server:

    // Declare connection path and video ID
    public var connURI:String = "rtmp://{your server}/dvr";
  7. Declare the public String property vidID and set it equal to "myDVR":

    // Declare connection path and video ID
    public var connURI:String = "rtmp://{your server}/dvr";
    public var vidID:String = "myDVR";
  8. Open the VideoPublisher.as file in the {start files}/DVR-FlashConsumerPublisher/com/realeyes/dvr/ directory and locate the following comment that begins:

    //Attach cam
  9. Under this comment, call the attachCamera() method on the _ns NetStream object and pass it the cam variable:
    //Attach cam, audio, and publish, also display in video for monitoring
    _ns.attachCamera( cam );
  10. Attach the sound by calling the attachAudio() method on the _ns NetStream object and pass it the result of the call to Microphone.getMicrophone():

    //Attach cam, audio, and publish, also display in video for monitoring
    _ns.attachCamera( cam );
    _ns.attachAudio( Microphone.getMicrophone() );
  11. Call the publish() method on the _ns method and pass it the vidID property as the first parameter and the String "record" as the second parameter:

    //Attach cam, audio, and publish, also display in video for monitoring
    _ns.attachCamera( cam );
    _ns.attachAudio( Microphone.getMicrophone() );
    _ns.publish( vidID, "record");
  12. To complete the _onPublish() method, call the attachCamera() method on the publisherVideo Video object and pass it the cam variable as its only parameter:

    //Attach cam, audio, and publish, also display in video for monitoring
    _ns.attachCamera( cam );
    _ns.attachAudio( Microphone.getMicrophone() );
    _ns.publish( vidID, "record");
    publisherVideo.attachCamera( cam );
  13. Return to the DVR-FlashConsumerPublisher.fla file and test the SWF in Flash (Control > Test Movie). If you have a camera attached, you should be able to click the Publish button and see the video you are broadcasting.

Now you have created the functionality to publish your video to the server and record it. Next, you need to create the functionality for consuming video that has been DVR-enabled. Once you are done with the next walkthrough, you will be able to play back the DVR-enabled video.