Netstream object for PostgreSQL Programming

Source: Internet
Author: User
Tags flv file
A netstream object transmits audio and video streams between all online objects. If you only want to pass text chat content, you can use shared objects instead of using them.
The basic attributes of this object are:
Time until now, the number of seconds for streaming data playback
Maximum number of seconds in the buffertime Buffer
Currentfps current video playback speed (frames per second)
Bufferlength: the number of seconds of data in the current buffer.
Livedelay video stream playback Interval
However, when you want to know the total length of the currently played image, you must call the method on the server side, because the flash player on the client cannot know the total length of the data stream. You need to write the following method on the client: 01: function getinfo ()
02 :{
03: NC. Call ('sendinfo', new myresultsetname (), mystream );
04 :}
05: function myresultsetname ()
06 :{
07: This. onresult = function (retval)
08 :{
09: _ root. streamlength = retval;
10 :};
11: This. onstatus = function (Info)
12 :{
13: trace ('level: '+ info. Level + 'Code:' + info. Code );
14: // process error object
15 :};
16 :}

Then, write: 01: application. onappstart = function () in the main. ASC file on the server ()
02 :{
03: trace (': application has started :::');
04 :}
05: application. onconnect = function (client)
06 :{
07: application. acceptconnection (client );
08: // Add Methods
09: client. Prototype. sendinfo = function (name ){
10: var slen = stream. Length (name );
11: trace ('slen: '+ slen );
12: Return slen;
13 :};
14 :}

For more information, see:
Setbuffertime (seconds)
You can set the buffer size to improve low-quality network conditions.
Note: The bufferlength size is always not greater than buffertime.

Attachvideo (image source, [shooting mode])
Append the video of the camera object to the streaming object. If the image source is null, the capture will stop.
If the shooting mode is omitted, consecutive images are captured. If the value is 0, only cell images are taken. If the value is greater than 0, cell images are taken at intervals of seconds.

Attactaudio (sound source)
Set the microphone audio source to the streaming object

Publish (Stream Data name, [broadcast mode])
If the stream data name is not specified, the stream is stopped.
The broadcast method is live (default value), which is real-time but not stored. record is also played by the streaming data name. FLV file storage, the path is the streams folder under the Application Path; append is appended to the FLV file with the specified name when the append is broadcast. If it does not exist, it is automatically created.

Pause ()
Pause and start playing

Close ()
Stop publishing or play all current data streams, and set netstream. the time attribute is set to 0 so that other clients can use the data stream. This method is used when netstream is used. play () or netstream. publish () is implicitly called.

Play (Stream name, start time, length, whether to clear the previous Stream)
The default start time is-2, indicating that flash will first try to play real-time audio and video; otherwise, it will play a file with a specified name.
If the value is-1, only the real-time audio and video will be played. If the value is 0, only the video content with the specified name will be played.
The length parameter specifies the number of seconds for audio/video playback. The default value is-1, indicating that the video is played until it ends. The value is other values, indicating that the video is played to the specified number of seconds.

Receivevideo (FPS)
When the playback stream speed is set to 0, flash will stop playing the image.

Seek (seconds)
The image with the specified number of seconds to be reversed. If it is set to 0, it will jump to the beginning.
You can use relative time to redirect, as shown in figure
Client_ns.seek (client_ns.time-3)

If you want to transfer audio or video streams, including text data, that is, data exchange, you can use the send method.
You can include the following ActionScript in the Client: 1: var my_nc: netconnection = new netconnection ();
2: my_nc.connect ('rtmp: // myserver.mydomain.com/appname/appinstance ');
3: var my_ns: netstream = new netstream (my_nc );
4: my_ns.publish ('slav', 'live ');
5: my_ns.send ('fun ', 'This is a test');,-1,-1 );
5:
6: my_ns.fun = function (STR) {// fun is the handler name
7: trace (STR );
8 :}

The following code can be used at the receiving end: 1: var my_nc: netconnection = new netconnection ();
2: my_nc.connect ('rtmp: // myserver.mydomain.com/appname ');
3: my_ns = new netstream (my_nc );
4: my_ns.play ('slav'

Several Methods to disable video streams: 1: mystream_ns.publish (false); // stop the entire stream.
2: mystream_ns.close (); // close the stream. Of course, streaming playback stops.
3: mystream_ns.attachvideo (null); // The video is only stopped and the audio is still played.

Related Article

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.