Highlighted

Load mp4 from Server and Save local

New Here ,
Sep 14, 2014

Copy link to clipboard

Copied

Hello,

i want to load a video from a server and save it on the HDD.

Here is my Code:

var loader:URLLoader = new URLLoader();

loader.load(new URLRequest("http://178.62.142.45/media/filer_public/d7/54/d754171a-f63b-4d62-923b-36619fd5dbc5/1.mp4"));

loader.addEventListener(Event.COMPLETE, onLoadComplete);

//Event Handler

var ba:ByteArray  = loader.data;

When the Movie is loaded, i get an error, when i try to write the loader.data into the byteArray;

error #1034

TOPICS
Development

Views

329

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Load mp4 from Server and Save local

New Here ,
Sep 14, 2014

Copy link to clipboard

Copied

Hello,

i want to load a video from a server and save it on the HDD.

Here is my Code:

var loader:URLLoader = new URLLoader();

loader.load(new URLRequest("http://178.62.142.45/media/filer_public/d7/54/d754171a-f63b-4d62-923b-36619fd5dbc5/1.mp4"));

loader.addEventListener(Event.COMPLETE, onLoadComplete);

//Event Handler

var ba:ByteArray  = loader.data;

When the Movie is loaded, i get an error, when i try to write the loader.data into the byteArray;

error #1034

TOPICS
Development

Views

330

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 14, 2014 0
Engaged ,
Sep 17, 2014

Copy link to clipboard

Copied

I took your example and modified it slightly and got no error. Before I modified it, Flash CS6 froze on my machine and I had to force quit it. I think it comes from trying to have the ByteArray be set equal to the Loader.data property. I changed it so that the ByteArray is a new ByteArray() and wrote the data to the array once the load finished and it seems to work fine.

import flash.events.Event;

import flash.events.ProgressEvent;

import flash.net.URLLoader;

import flash.net.URLRequest;

import flash.utils.ByteArray;

var ba:ByteArray = new ByteArray();

var loader:URLLoader = new URLLoader();

loader.addEventListener(Event.COMPLETE, onLoadComplete);

loader.addEventListener(ProgressEvent.PROGRESS, onProgress);

loader.load(new URLRequest("http://178.62.142.45/media/filer_public/d7/54/d754171a-f63b-4d62-923b-36619fd5dbc5/1.mp4"));

function onProgress(e:ProgressEvent):void {

  trace(int(100 * (e.bytesLoaded / e.bytesTotal)) + "%");

}

function onLoadComplete(e:Event):void {

  ba.writeObject(loader.data);

  trace(ba.length);

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 17, 2014 0