Skip to main content
Inspiring
March 29, 2017
Question

loading mp4 file in to ipad

  • March 29, 2017
  • 1 reply
  • 461 views

dear frieds,

I want to load mp4 file in ios, its loading in desktop while testing, not loading in ipad. pls help me iam using following code:

var nc: NetConnection = new NetConnection();
nc.connect(null);

var ns: NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play("video.mp4");
function asyncErrorHandler(event: AsyncErrorEvent): void {
trace(event);
// ignore error
}

var vid: Video = new Video();
vid.attachNetStream(ns);
vid.width = 640;
vid.height = 360;
addChild(vid);

Thanks and Regards,

Syed Abdul Rahim

This topic has been closed for replies.

1 reply

itlancer
Inspiring
March 29, 2017

Here is bug report: Tracker

It's AIR limitation for iOS. You can use StageVideo or VideoTexture with Stage3D to play mp4 video with iOS.

Colin Holgate
Inspiring
March 29, 2017

The code for using StageVideo is basically the same as you're already doing. To attach the netstream to StageVideo is done like (where _ns is your netstream):

private var _stageVideo: StageVideo;

private function _enableStageVideo(): void {

  if (_stageVideo == null) {

  _stageVideo = _stage.stageVideos[0];

  _stageVideo.viewPort = _rect;

  }

  _stageVideo.attachNetStream(_ns);

  }

StageVideo appears in the background, and you can put regular buttons on top of it without affecting performance.