Skip to main content
Inspiring
August 28, 2017
Question

loading flv with netstream in AirforIOS

  • August 28, 2017
  • 0 replies
  • 269 views

Dear Friends,

Iam creating an elearning app, in that iam loading a flv video its loading fine. working well. If I move to next slide while loading the flv video, the vo is playing behind. If I move to next slide after the flv loaded, there is no issue. Pls tell me the way to track whether the flv is still loading? iam using the following code to load my flv video.

import flash.display.Sprite;

import flash.events.NetStatusEvent;

import flash.events.SecurityErrorEvent;

import flash.media.Video;

import flash.net.NetConnection;

import flash.net.NetStream;

import flash.events.Event;

var videoURL: String = "testvideo.flv"
var connection: NetConnection;
var stream: NetStream;
var video: Video = new Video();
video.width = 640;
video.height = 360;
video.x = 0;
video.y = 0;
NetConnectionExample()


function NetConnectionExample() {
connection = new NetConnection();
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
connection.connect(null);
}

function netStatusHandler(event: NetStatusEvent): void {
trace("Stream Status :" + event.info.code);
switch (event.info.code) {
  case "NetConnection.Connect.Success":
   connectStream();
   break;
  case "NetStream.Play.Start":
   break;
  case "NetStream.Play.StreamNotFound":
   break;
  default:

   if (this.name != "video_mc") {
    stream.seek(0);
    stream.pause();
    stream.close();
   }
   break;
}
}

function securityErrorHandler(event: SecurityErrorEvent): void {
trace("securityErrorHandler: " + event);
}

function connectStream(): void {
addChild(video);
var stream: NetStream = new NetStream(connection);
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stream.client = this;
video.attachNetStream(stream);
stream.play(videoURL);
}

Thanks and Regards,

Syed Abdul Rahim

This topic has been closed for replies.