Skip to main content
Participant
July 9, 2014
Question

Adobe Media Server - ByteArray

  • July 9, 2014
  • 1 reply
  • 370 views

How are you supposed to access the data in a ByteArray? ByteArray.readBytes reads into another byte array which perpetuates the problem. I want to return the data so that I can manipulate it. What am I missing?

    var data  = new ByteArray();

    var file  = new File(path);

    var pos   = 0;

    var bytes = 500 * 1024; // bytes

    if( !file.exists ) {

        trace(path + ' does not exist');

        return;

    }

   /*

    | Opens an FLV file in binary mode

    */

    if( !file.open('binary', 'read') ) {

         trace('Cannot open file');

         return;

    }

    if( file.length < bytes ) {

        bytes = file.length;

    }

    

    /*

    | Neither valueOf or toString provide the data I want.

    | Both return "FLV" as a value not the data.

    */

    file.readBytes(data, pos, bytes);

    trace(data.valueOf());  // DOES NOT WORK

    trace(data.toString()); // DOES NOT WORK

    This topic has been closed for replies.

    1 reply

    Robert Mc Dowell
    Legend
    January 21, 2018

    Thread little old, but I guess that a serialization of bytes was needed here.