Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8419131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:31:38+00:00 2026-06-10T02:31:38+00:00

This code is way cool! Try it. It creates a folder in your user

  • 0

This code is way cool! Try it. It creates a folder in your user called .007 and saves an mp3 called yahoo.mp3.

It will also do it on an android device if permissions are set correctly.

Once it creates a folder and saves the mp3 it will loop thru the folder and get the file path and the file name.

MY QUESTION IS: How do you access it and play the sound on Android? It works on the desktop as you can see if you test it But not on the droid. Any ideas why?

import flash.filesystem.*;
var urlString:String = "http://YourWebsite.com/YourSound.mp3";
var urlReq:URLRequest = new URLRequest(urlString);
var urlStream:URLStream = new URLStream();
var fileData:ByteArray = new ByteArray();
urlStream.addEventListener(Event.COMPLETE, loaded);
urlStream.load(urlReq);

function loaded(event:Event):void
{
    urlStream.readBytes(fileData, 0, urlStream.bytesAvailable);
    writeAirFile();
}

function writeAirFile():void
{

    var file:File = File.userDirectory.resolvePath(".007/Yahoo.mp3");
    var fileStream:FileStream = new FileStream();
    fileStream.open(file, FileMode.WRITE);
    fileStream.writeBytes(fileData, 0, fileData.length);
    fileStream.close();
    trace("The file is written.");

    var desktop:File = File.userDirectory.resolvePath(".0");
    var files:Array = desktop.getDirectoryListing();
    for (var i:uint = 0; i < files.length; i++)
    {
        trace(files[i].nativePath);// gets the path of the files
        trace(files[i].name);// gets the name


        var mySound:Sound = new Sound();
        var myChannel:SoundChannel = new SoundChannel();
        var lastPosition:Number = 0;
        mySound.load(new URLRequest(files[0].nativePath));
        myChannel = mySound.play();

    }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:31:39+00:00Added an answer on June 10, 2026 at 2:31 am

    file:// <——-The Answer!

    Got it! The file path needed to access the “sdcard” on a Android phone must begin with: file://

    If you want to load a sound from your phone it would look like this. Here is the one important line needed. I will post full code below.

    mySound.load(new URLRequest("file://mnt/sdcard/AnyFolder/YourSound.mp3"));
    

    Since I was using a loop above getting all the files in a particular folder this is the code that worked for me in the example above.

    mySound.load(new URLRequest("file://"+files[0].nativePath));
    

    FULL CODE TO LOAD AND PLAY SOUND ON DROID

    var mySound:Sound = new Sound();
    var myChannel:SoundChannel = new SoundChannel();
    var lastPosition:Number = 0;
    mySound.load(new URLRequest("file://mnt/sdcard/AnyFolder/YourSound.mp3"));
    myChannel = mySound.play();
    

    I worked very hard on to find this answer. I hope this helps many. Please remember to +1 if this code has helped you. 🙂

    I love StackOverflow! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get the results of this code this way: title: Ben
I have this code (which is way simplified from the real code): public interface
When I remove the DOCTYPE line this code works the way I want it
Must be a way looping through this code: private void loadSprites() { this.sprites[0] =
There's another way to write this code ? I think it's kinda unprofessional and
Is there a way to make this code work? LogonControl.java @Audit(AuditType.LOGON) public void login(String
Is there any way to refactor this code so that it can omit unnecessary
Is there a better way to code this? def __contains__(self, e): return e in
Is there any possible way to edit this code <asp:LoginName ID=LoginName1 runat=server style=top: 165px;
Could anyone find a way of improving this code a bit? I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.