0

I am getting the result for event.bytesTotal = 0 in some of the mp3 file when i am loading it from ftp server.But
when loading the same file from local server, the call to event.bytesTotal is working well - giving the expected result.

Here is my code :

 public function LoadedBytes()
        {
            var byteLoader:URLLoader = new URLLoader();
            byteLoader.dataFormat = URLLoaderDataFormat.BINARY;

            var fileRequest:URLRequest = new URLRequest();

            myFile =new File();
            myFile=File.desktopDirectory; 
            myFileStream = new FileStream();

            fileRequest.url="http://minhajproductions.in/irfanulquran/Al-Fatihah/4.mp3";

            myFile=File.desktopDirectory;  
            myFile=myFile.resolvePath("sound/4.mp3");

            try{
                byteLoader.addEventListener(ProgressEvent.PROGRESS,onProgress);
                byteLoader.load(fileRequest);
            }catch(e:IOError){
                trace("unable to load requested sound")
            }



        }

        protected function onProgress(event:ProgressEvent):void
        {
            trace(event.bytesLoaded,event.bytesTotal," length");
            //progressCB((event.bytesLoaded/event.bytesTotal));

        }

why this weird thing is happening? Thanks in advance.

TKV
  • 2,533
  • 11
  • 43
  • 56
Kaif
  • 131
  • 1
  • 12
  • I tried your code with no change. It is working fine. – Rajneesh Gaikwad Feb 13 '14 at 09:21
  • Have you downloaded that sound? What is the size of that sound? its working at your side may be because i changed 4.mp3 yesterday several times for testing.For sounds whose size is less than 50kb event.bytesTotal is giving correct result but for large file like i have its giving 0. :-( – Kaif Feb 14 '14 at 05:38
  • I have not downloaded it. I am loading it from the same URL. – Rajneesh Gaikwad Feb 14 '14 at 05:58
  • BTW, Are you trying to download that file? Why `File()` and `FileStream()`. Also `myFile=File.desktopDirectory;` is written twice. – Rajneesh Gaikwad Feb 14 '14 at 06:01
  • Yes i have to save file.I used File and FileStream to save downloaded file.myFile=File.desktopDirectory(twice) sorry its my mistake. – Kaif Feb 14 '14 at 06:30
  • Why don't you try `Event.OPEN` or try with `HTTPStatusEvent.HTTP_STATUS` and check for statuses, or `SecurityErrorEvent.SECURITY_ERROR` so that you can get some light ray in the dark. – Rajneesh Gaikwad Feb 14 '14 at 07:02
  • Getting event.status 200 in HTTPStatusEvent.HTTP_STATUS,no security error.Actually everything is working fine,my file gets saved in desired location but in ProgressEvent bytesTotal value is 0. And i want to add a downloading Bar so that user can know how much data have been downloaded so for this i need bytesTotal. – Kaif Feb 14 '14 at 10:36

2 Answers2

1

My problem was the missing Content-Length header on my server side. Flash use it to be able to find the download progression.

Nek
  • 2,715
  • 1
  • 20
  • 34
0

I think there is problem at your end. Try running the same program from some other place.

I found one post event-bytestotal-returns-0

Check the first answer in which Chunked_transfer_encoding link is given for more info.

Community
  • 1
  • 1
Rajneesh Gaikwad
  • 1,193
  • 2
  • 14
  • 30