FLV software control
Hello.
Software control of FLV video can be done using NetStream.
To begin with, let's create a new symbol in the library - a video. Next, drag it onto the stage and this empty box will serve as our container where we will upload our video. We set its size according to the size of the video that we are going to play. Let's name the videoContainer symbol.
In the frame we write: Functions for working with video:
var nс:NetConnection = new NetConnection(); // Создаем объект NetConnection:
nс.connect(null); // Активируем соединение
var ns:NetStream = new NetStream(nс); // Создаем объект NetStream
videoContainer.attachVideo(nc); // Прикрепляем видео к нашему контейнеру
ns.play("video.flv"); // Путь к файлу и сразу начинаем проигрывать.
- NetStream.play (“filename”) - The name and path to the file.
- NetStream.close () - stops file loading.
- NetStream.pause () - puts (true) / removes (false) pause.
- NetStream.seek (seconds) - Rewinds the video for the required number of seconds ahead. Report to see from the beginning of the video.
- NetStream.setBufferTime (seconds) - sets the buffer capacity - how many seconds the video loads before it starts on the screen.
- NetStream.bufferLength - [read only] - number of downloaded seconds of video to the buffer.
- NetStream.bufferTime - [read only] - shows the buffer capacity (which can be changed with a command.
- NetStream.setBufferTime (number of seconds)). Default = 0.1 seconds.
- NetStream.bytesLoaded - [read only] - how many bytes of video have already been loaded.
- NetStream.bytesTotal - [read only] - how many total bytes are in the downloaded video.
- NetStream.currentFps - [read only] - how often (how many frames per second) the video plays.
- NetStream.time - [read only] - the current position of the video, in seconds.
- NetStream.onStatus - an event that carries information about the status of a NetStream object
Example use of onStatus: Event options:
NetStream.onStatus = function(infoObject)
{
status.text += "Status (NetStream)" + newline;
status.text += "Level: "+infoObject.level + newline;
status.text += "Code: "+infoObject.code + newline;
};
- code = NetStream.Buffer.Empty, level = Status - the date does not load quickly enough to fill the buffer. When the buffer is full and NetStream.Buffer.Full status comes, the playback will continue.
- code = NetStream.Buffer.Full, level = Status - the buffer is full, the stream is running
- code = NetStream.Play.Start = Status - playback started
- code = NetStream.Play.Stop = Status - playback stopped
- code = NetStream.Play.StreamNotFound = Error - failure. Skip play () (Maybe the stream is already busy)
Then you can create a couple of buttons, set a play and stop event in them and our player is ready.
You can also synchronize the video with the timeline and manage it, or simply upload via setMedia (); Look like that's it.