Skip navigation
murat.dikici
Currently Being Moderated

Full screen native video player in iPad

Jun 11, 2012 5:04 AM

Tags: #air #video #as3 #ios #ipad #as3.0 #player #actionscript3 #native

Hello,

 

I built an iPad app on Flash CS6 using air sdk 3.2. In the app, there is a button to play a video. I want it to play the video in native video player of iPad fullscreen.

 

I tried two methods :

1. navigateToURL() function. In this method, it first opens a web browser and then plays the video in separate native video player. I don't want it open a web browser first. Here is the code i used :

var req:URLRequest = new URLRequest(videoURL);

navigateToURL(req, "_self");

 

2. StageWebView component. In this method, clicking the button draws the video player on the app 100% size of the stage. But in the video player, there is fullscreen button. When you click it, it makes no change on the video player size but it changes the style of the video player (video scroller comes to top of the video, sound controller comes, etc.) So, this may make people confusing. Here is the code :

public var webView:StageWebView = new StageWebView();

webView.stage = this.stage;

webView.viewPort = new Rectangle( 0, 0, stage.width, stage.height);

webView.loadURL(videoURL);

 

I need a clear solution which opens a fullscreen native video player when i click the button. Please help me.

 

Thanks

 
Replies
  • Currently Being Moderated
    Jun 11, 2012 9:56 AM   in reply to murat.dikici

    I'm facing the same problem here. anyone can help?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 14, 2012 12:30 AM   in reply to murat.dikici

    Hi,

     

    I don't know about the native video player, but I'm working on similar type of functionality, and we can play flash video in iPad, if you need the help without using the native video player then I can provide you the code.

     

    Regards,

    Vipul

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 14, 2012 2:23 AM   in reply to murat.dikici

    Hi,

     

    See the code below

    --------------------------------------------

     

    package

    {

              import flash.display.MovieClip;

              import flash.events.Event;

              import flash.media.Video;

              import flash.net.NetConnection;

              import flash.net.NetStream;

              import flash.events.NetStatusEvent;

     

              public class VideoImporter extends MovieClip

              {

                        public var vid:Video = new Video();

                        public var netStreamObj:NetStream;

                        public static var instance:VideoImporter;

     

                        public static function getInstance():VideoImporter

                        {

                                  if (instance == null)

                                  {

                                            instance = new VideoImporter();

     

                                  }

                                  return instance;

                        }

     

                        public function VideoImporter()

                        {

                                  instance = this;

                                  init();

                        }

     

                        private function init():void

                        {

                                  vid.width = 1024;

                                  vid.height = 768;

     

                                  var nc:NetConnection = new NetConnection();

                                  nc.connect( null );

                                  netStreamObj = new NetStream( nc );

                                  netStreamObj.bufferTime = 5;

     

                                  netStreamObj.client = this;

                                  netStreamObj.addEventListener( NetStatusEvent.NET_STATUS, onStatus );

                        }

     

                        private function onStatus( event:NetStatusEvent ):void

                        {

                                  switch( event.info.code )

                                  {

                                            case "NetStream.Buffer.Empty":

                                                      //show buffering graphic

                                                      break;

                                            case "NetStream.Buffer.Full":

                                                      //hide buffering graphic

                                                      break;

     

                                            case "NetStream.Play.Stop":

                                                      netStreamObj.seek(0);

                                                      break;

                                  }

     

                        }

     

                        public function onMetaData( info:Object ):void

                        {

                                  trace( info );

                        }

     

                        public function onXMPData( info:Object ):void

                        {

                                  trace( info );

                        }

                        public function playVideo(pathStr:String,targetMc:MovieClip):void

                        {

                                  targetMc.addChild(vid);

                                  netStreamObj.play(pathStr);

                                  vid.attachNetStream(netStreamObj);

     

                        }

              }

     

     

    }

     

     

    You can use this class for importing your video in iPad, just call the playVideo method in your class, parameters are pathStr: path of your video file in your project and targetMc : movieclip in which you want to show your video. In the above class video size is 1024 X 768, as per ipad resolution, if you want to some other resolution, you can change that accordingly.

     

    Please be sure about the video format, it only plays .FLV and .MP4 formats.

     

    I'm using this calss in my project and this is working perfectly, If any error occurs, I'm open for that.

     

    Regards,

    Vipul

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points