How to edit an mp3 file that has been uploaded to flash via the fileReference.browse () method?

I wonder how I can work with mp3 that was uploaded to Flash using the fileReference.browse () method?

Currently, I have created a lash application that can download an mp3 file from a local hard drive to flash and provide the ability to save an mp3 file that was downloaded back to the hard drive. But I can not find a way to work with mp3 that has been downloaded. I heard about the flash editor that will be available in Aviary. (Http://aviary.com/blog/posts/aviary-acquires-digimix), so there is a way to work with mp3 in Flash, but how?

Here is my code:

import flash.net.FileReference;      
import flash.net.FileFilter;
import flash.utils.ByteArray;
import flash.display.MovieClip;
import flash.net.*;
import flash.events.*;
import flash.media.Sound;
import flash.media.SoundChannel;



var fileReference:FileReference;
var myChannel:SoundChannel;
var mySound:Sound;
var mySprite:Sprite;
var mySprite2:Sprite;

mySound=new Sound();
myChannel=new SoundChannel();


load_btn.addEventListener (MouseEvent.CLICK, onLoadClick);
unload_btn.addEventListener (MouseEvent.CLICK, onUnloadClick);

function onLoadClick ( event:MouseEvent):void

{
    fileReference=new FileReference();
    var allTypeFilter:FileFilter = new FileFilter("mp3: (*.mp3)","*.mp3");
    fileReference.browse([allTypeFilter]);
    fileReference.addEventListener(Event.SELECT, selectHandler);

}

function selectHandler(event:Event):void
        {
            fileReference.removeEventListener(Event.SELECT, selectHandler);
            fileReference.addEventListener(Event.COMPLETE, loadCompleteHandler);
            fileReference.load();
        }

function loadCompleteHandler(event:Event):void
        {
            fileReference.removeEventListener(Event.COMPLETE, loadCompleteHandler);

            var loader:Loader = new Loader();
            //loader.contentLoaderInfo.addEventListener(Event.COMPLETE, startPlay);
            loader.loadBytes(fileReference.data);
        }

function onUnloadClick (event:MouseEvent)

{
    trace(fileReference.data);
    fileReference.save(fileReference.data, "done.mp3");

}

Thanks in advance.

+3
source share
1 answer

. - API FileReference ByteArray, ( ) MP3 SWF, flash.display.Loader.loadBytes.

. Sound extract() PCM, .

MP3 PCM, , mp3-, .

0

Source: https://habr.com/ru/post/1795990/


All Articles