12 Replies Latest reply: Jan 6, 2014 8:48 AM by TavaresEd RSS

    Help with video player for android app.

    TavaresEd Community Member

      Hi!

      I am trying to make an app for android that will play a video file hosted on my webserver.

       

      this is the code I have so far but it is not showing the video playing.

       

      This code is inside a sets.swf file the is loaded into an empty movieclip that is inside main.swf.

       

       

      import flash.utils.Timer;

      import flash.events.TimerEvent;

       

      var video:Video;

      var nc:NetConnection;

      var ns:NetStream;

      var t : Timer = new Timer(1000,0);

      var meta:Object = new Object();

       

      this.addEventListener(Event.ADDED_TO_STAGE,init);

       

      function init(e:Event):void{

      video= new Video(320, 240);

      addChild(video);

      video.x = 80;

      video.y = 100;

       

      nc= new NetConnection();

      nc.connect(null);

      ns = new NetStream(nc);

      ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);

      ns.bufferTime = 1;

       

      ns.client = meta;

      video.attachNetStream(ns);

       

      ns.play("http://www.djchambinho.com/videos/segundaquinta.flv");

      ns.pause();

       

      t.addEventListener(TimerEvent.TIMER,timeHandler);

      t.start();

      }

       

      function onStatusEvent(stat:Object):void

      {

                trace(stat.info.code);

      }

       

      meta.onMetaData = function(meta:Object)

      {

                trace(meta.duration);

      }

       

       

      function timeHandler(event : TimerEvent) : void

      {

       

        if (ns.bytesLoaded>0&&ns.bytesLoaded == ns.bytesTotal )

        {

                  ns.resume();

                  t.removeEventListener(TimerEvent.TIMER,timeHandler);

                  t.stop();

        }

      }

       

      thank you