Network Video Conferencing II

Source: Internet
Author: User
Tags dedicated server flv file
Basic knowledge about Video Processing

An important feature of Adobe Flash Player is the ability to display and operate video information in the form of other visual content (such as, animation, text, and so on) using ActionScript.

When creating a Flash video (FLV) file in Adobe Flash CS3 professional, you can select the video appearance, including common playback controls. However, you do not have to be limited to available options. You can accurately control the loading, display, and playback of videos by using ActionScript, which means you can create your own video player appearance or use videos in any non-traditional mode as needed.

Using videos in ActionScript involves the joint use of multiple classes:

  • Video class: the actual video content frame on the stage is an instance of the video class. Video is a display object, so you can use the same technology for other display objects (such as positioning, application deformation, application filter and mixed mode) for operations.
  • Netstream class: when loading a video file that will be controlled by ActionScript, A netstream instance is used to represent the video content source. In this example, the video data stream is used. Using a netstream instance also involves the use of a netconnection object, which is a connection to a video file. It is like a channel for video data feed.
  • Camera: When video data is processed by a camera connected to a user's computer, a camera instance is used to represent the video content source, that is, the user's camera and the video data it provides.

When loading external videos, you can load files from the standard Web server for progressive download and playback, or use video streams sent by dedicated servers (such as Adobe's Macromedia Flash Media Server.

Common video tasks

This chapter describes the following video-related tasks you want to perform:

  • Display and control the video on the screen
  • Load External FLV files
  • Process metadata and prompt information in video files
  • Capture and display video input from the user's camera
Important concepts and terms
  • Tip: a tag that can be placed in a video file at a specific time point. For example, it can be used as a bookmark to locate the time point or provide other data associated with the time point.
  • Encoding: the process of receiving video data in one format and converting it into another video data format. For example, receives a high-resolution source video and converts it to a format suitable for Internet transmission.
  • Frame: a single piece of video information. Each frame is similar to a static image that represents a snapshot at a certain time point. By playing each frame in sequence at a high speed, you can produce an animated visual effect.
  • Key Frame: the video frame that contains the complete information of the frame. Other frames after a key frame only contain information about their differences with the key frame, not the complete frame information.
  • Metadata: Information about video files can be embedded in video files and retrieved when videos are loaded.
  • Progressive download: When a video file is transmitted from a standard Web server, the progressive download is used to load the video data, which means that the video information is loaded in sequence. The advantage is that you do not have to wait until the entire file is downloaded to start playing the video; however, it will prevent you from jumping forward to the part that has not been loaded in the video.
  • Stream Transmission: an alternative to progressive download, which uses stream transmission (sometimes called "real stream") technology and a dedicated video server to transmit videos over the Internet. Streaming Transmission is used, and the computer used to view the video does not need to download the entire video at a time. To speed up the download, the computer only needs part of the video information at any time. Because a dedicated server is used to control the transmission of video content, you can access any part of the video at any time without waiting for the download to complete.
Complete the examples in this Chapter

When learning this chapter, you may want to test some sample code lists by yourself. As this chapter describes how to use videos in ActionScript, many code lists in this chapter involve video objects (which may be objects created and placed on the stage in Flash creation tools, it may also be an object created using ActionScript ). The test example involves viewing the results in Flash Player to understand the impact of code on the video.

Most sample code lists operate on a video object without explicitly creating the object. To test the code list in this chapter, perform the following operations:

  1. Create an empty flash document.
  2. Select a key frame on the timeline.
  3. Open the action panel and copy the code list to the script pane.
  4. Open the "Database" panel if necessary.
  5. From the "Database" Panel menu, select "new video ".
  6. In the "video attributes" dialog box, enter the name of the new video element, and select "video (subject to the control of ActionScript)" in the "type" field )". Click OK to create a video element.
  7. Drag an instance of the video component from the "repository" panel to the stage.
  8. Keep the video instance selected. In the "properties" checker, specify the Instance name. The name should match the name used by the video instance in the sample code list. For example, if the name of the code list operation isvidThe stage instance should also be namedvid.
  9. Use "control"> "test film" to run the program.

    On the screen, you will see the video operation results according to the requirements specified in the code list.

Some sample code lists in this chapter include not only sample code, but also class definitions. In these lists, apart from the first few steps, you also need to create classes used in the example before testing SWF. To create a class defined in the sample code list, perform the following operations:

  1. Make sure that the FLA file for testing is saved.
  2. Select "file"> "new" from the main menu ".
  3. In the "type" section of the "new document" dialog box, select "ActionScript File ". Click OK to create a new ActionScript file.
  4. Copy the class definition code from the example to the ActionScript document.
  5. Select "file"> "save" from the main menu ". Save the file in the directory where the flash file is located. The file name should be consistent with the name of the class in the code list. For example, if the Code List defines a class named "videotest", save the ActionScript file as "videotest. ".
  6. Return to the Flash document.
  7. Use "control"> "test film" to run the program.

    You will see the sample results on the screen.

  8. Netstream

  9. ActionScript 3.0 language and component reference All packages | all classes | language element | Index
    | Appendix | conventions | no frame
    Netstream Attribute | method | event | example
     

    Package Flash.net
    Class Public class netstream
    Inheritance Netstream eventdispatcher object

     

    Language version: Event 3.0
    Player version: Flash Player 9

     

     

    The netstream class opens the Flash Player and server through the connection provided by the netconnection object (for example, Adobe's Macromedia Flash Media Server 2 or Adobe Flex) or a one-way stream connection between flash player and the local file system. The netstream object is similar to a channel in the netconnection object. This channel can be usedNetStream.publish()Publish audio and/or video data. You can also useNetStream.play()Subscribe to published streams and receive data. You can publish or play real-time data and previously recorded data. You can also use the netstream object to send text messages to all subscribed clients (seeNetStream.send()Method ).

    Compared with embedding a video in a flash file, playing an external FLV file has multiple advantages, such as better performance and memory management, as well as independent video and flash frame rates. This class provides several methods and attributes that you can use to track the progress of a file when it is loaded and played, and to allow users to control the playback (stop or pause ).

    Some attributes and methods in the netstream class are mainly used for servers (such as Flash Media Server or flex ). They may contain more server functions. For other documents, see the netstream class in Flash Media Server documentation.

    The general workflow of audio streams or video streams.The following steps summarize the general operation sequence required to publish real-time audio and video:

    1. Create a netconnection object.
    2. UseNetConnection.connect()Method to connect the application instance to the server.
    3. Create a netstream object to create a data stream through this connection.
    4. UseNetStream.attachAudio()Method to capture and send audio using the stream.NetStream.attachVideo()This method captures and sends videos.
    5. UseNetStream.publish()Method to assign a unique name to the stream and send the data to the server through the stream so that other users can receive the data. You can also record data when publishing data so that you can play back the data later.

      The SWF file that subscribes to this stream will be calledplay()Use to passpublish()And the name ofNetConnection.connect()Method. They must be calledVideo.attachNetStream()Method for stream processing and calling of videosNetStream.play()Method To play a video.

     

    View examples

    For more information, see

    Flash. Media. Video
    Flash.net. netconnection
    Send ()
    Basic video knowledge

    Hide inherited public properties show inherited public properties
      Attribute Definer
        Bufferlength: Number

    [Read-Only] The number of seconds in which the data currently exists in the buffer.
    Netstream
        Buffertime: Number

    Specifies how long it takes to store messages in the buffer before starting to display the stream.
    Netstream
        Bytesloaded: uint

    [Read-Only] the number of bytes of data loaded to the player.
    Netstream
        Bytestotal: uint

    [Read-Only] The total size (in bytes) of the file being loaded to the player ).
    Netstream
        Checkpolicyfile: Boolean

    Specify whether the Flash Player should try to download the cross-origin policy file from the server where the FLV file is loaded before it starts to load the FLV file.
    Netstream
        Client: Object

    Specifies the object on which the callback method is called.
    Netstream
      Constructor: Object

    References a class object or constructor of a given object instance.
    Object
        Currentfps: Number

    [Read-Only] The number of frames displayed per second.
    Netstream
        Livedelay: Number

    [Read-Only] The number of seconds in the buffer zone of the subscribed stream in real-time (unbuffered) mode.
    Netstream
        Objectencoding: uint

    [Read-Only] object encoding of this netstream object (AMF version ).
    Netstream
      Prototype: Object

    [Static] a reference to a prototype object of a class or function object.
    Object
        Soundtransform: soundtransform

    Controls sound in this netstream object.
    Netstream
        Time: Number

    [Read-Only] the position of the playback header (in seconds ).
    Netstream

    Hide inherited public methods show inherited public methods
      Method Definer
        Netstream (connection: netconnection) creates a stream that can be used to play FLV files through the specified netconnection object. Netstream
      Addeventlistener (type: String, listener: function, usecapture: Boolean = false, priority: Int = 0, useweakreference: Boolean = false): void registers the event listener object using the eventdispatcher object, to enable the listener to receive Event Notifications. Eventdispatcher
        Attachaudio (microphone: microphone): void specifies an audio stream sent through the netstream object, which comes from the microphone object transmitted as the source. Netstream
        Attachcamera (thecamera: Camera, snapshotmilliseconds: Int =-1): The Void starts capturing videos from the specified source, or if thecamera is set to null, the capture operation is stopped. Netstream
        Close (): void stops all data in the stream, sets the time attribute to 0, and enables the stream to be used for other purposes. Netstream
      Dispatchevent (Event: Event): Boolean schedules the event to the event stream. Eventdispatcher
      Haseventlistener (type: string): Boolean checks whether the eventdispatcher object registers any listener for a specific event type. Eventdispatcher
      Hasownproperty (Name: string): Boolean indicates whether the object has defined the specified attribute. Object
      Isprototypeof (theclass: Object): Boolean indicates whether the object class instance is in the prototype chain of the object specified as a parameter. Object
        Pause (): void pause video stream playback. Netstream
        Play (... arguments): void starts to play back external audio or video (FLV) files. Netstream
      Propertyisenumerable (Name: string): Boolean indicates whether the specified attribute exists and whether it can be enumerated. Object
        Publish (Name: String = NULL, type: String = NULL): void sends audio streams, video streams, and text message streams from the client to the server (for example, Flash Media Server 2 ), you can also choose to record the stream during transmission. Netstream
        Receiveaudio (FLAG: Boolean): void specifies whether the incoming audio is played in the stream. Netstream
        Receivevideo (FLAG: Boolean): void specifies whether the incoming audio will be played in the stream. Netstream
      Removeeventlistener (type: String, listener: function, usecapture: Boolean = false): void deletes the listener from the eventdispatcher object. Eventdispatcher
        Resume (): void resumes paused video streams. Netstream
        Seek (offset: Number): searches for the key frame closest to the specified position (offset calculated from the starting position of the stream, in seconds. Netstream
        Send (handlername: String,... arguments): void sends a message to all subscription clients on the specified stream. Netstream
      Setpropertyisenumerable (Name: String, isenum: Boolean = true): void sets the availability of dynamic attributes of cyclic operations. Object
        Togglepause (): void pause or resume stream playback. Netstream
      Tostring (): return the string representation of the specified object. Object
      Valueof (): the object returns the original value of the specified object. Object
     

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.