Skip navigation
Currently Being Moderated

netstream appendBytes()

Apr 14, 2011 6:22 AM

hi. i am trying to play a mp4 video file with netstream.appendbytes method. but the video down't loading. when i am load a flv video file, the player play the flv video but when i am trying a mp4 video file, don't loading. flv works, but mp4 don't works. why? Please help me!

my code is

 


import flash.net.URLRequest;
import flash.net.URLStream;
import flash.events.ProgressEvent;
import flash.events.Event;
import flash.utils.ByteArray;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.events.NetStatusEvent;


var urr:URLRequest;
var urs:URLStream;
var nc:NetConnection;
var ns:NetStream;
var vid:Video;
urr=new URLRequest("http://video.ak.fbcdn.net/cfs-ak-snc6/214988/655/115514355195743_26925.mp4?oh=53935006d42b2db7f970d41f07ab617d&oe=4DA8FD00&__gda__=1302920448_181887f1c8692424282dcc9b072f59a0");
urs=new URLStream();
urs.addEventListener(flash.events.ProgressEvent.PROGRESS,progresHnd);
urs.addEventListener(flash.events.Event.COMPLETE,completeHnd);
urs.addEventListener(flash.events.Event.CLOSE,closeHnd);
urs.addEventListener(flash.events.Event.OPEN,openHnd);
urs.load(urr);


function progresHnd(e:Object):void{
     trace (e);
     var bytes:ByteArray=new ByteArray();
     urs.readBytes(bytes,0,urs.bytesAvailable);
     ns.appendBytes(bytes);
     
     }
     
function closeHnd(e:Object):void{
     trace (e);
     }
     
function completeHnd(e:Object):void{
     trace (e);
     }
     
function openHnd(e:Object):void{
     trace (e);
     nc=new NetConnection();
     nc.connect(null);
     ns=new NetStream(nc);
     vid=new Video();
     vid.attachNetStream(ns);
     ns.play(null);     
     addChild(vid);
     }

 
 
Replies

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