Android :: Play Audio File From Assets Directory

Jul 20, 2010

when I run this code, it starts playing all the audio files in the assets directory, in alphabetical order instead of just playing the audio file I requested. What am I doing wrong? Is there a better way to play audio files from the assets directory?Is there a difference between keeping audio files in the assets directory and keeping them in the res/raw directory? Besides the fact that they don't get ids if they are in the assets directory. If I move the audio files to the res/raw folder then I have a problem with reusing MediaPlayers because there is no id parameter for setDataSource(). I can't find a good guideline for handling this kind of problem.

Android :: Play audio file from assets directory


Android :: Play Remote Audio File In Android Audio Player

Nov 12, 2010

I am working on a application that would allow users to play remote files. My question is how do I open those remote files to be played in the default android player?but this does not give me control of what is happening!

View 2 Replies View Related

Android :: Access Base Directory Assets From Another Application?

Mar 16, 2010

I get a lot of requests in my application to allow for custom icons packs from BetterCut / Open Home. The way it seems to work is you install BetterCut or Open Home, then you can install tons of these free icon packs from the market. Once installed both those apps (and other apps) will poll for those icon packs and use the icons. I want to know how to poll the install applications for the asset folders that are available. I have opened up a few of the icon packs and verified that there is an assets folder in there and they are full of all the icon png files. I've searched on here, other code sites, google, etc., but haven't found any leads.

From the answer below I have written some code to try and list a file from my own projects assets directory but it does not seem to work.
Resources r = this.getResources();
AssetManager a = r.getAssets();
String[] list = a.list("/");
Log.d("test", "Length of / is "+list.length);
for (String s : list) { Log.d("test", s); }
Log.d("test", "Length of /assets is "+a.list("/assets").length);
Log.d("test", "Length of /assets/ is "+a.list("/assets/").length);
Log.d("test", "Length of /assets/ is "+a.list("/assets/").length);
Log.d("test", "Length of ./assets/ is "+a.list("./assets/").length);
Log.d("test", "Length of ./assets is "+a.list("./assets").length);

This is the output:
03-16 12:25:04.591: DEBUG/test(13526): Length of / is 6
03-16 12:25:04.591: DEBUG/test(13526): AndroidManifest.xml
03-16 12:25:04.591: DEBUG/test(13526): META-INF
03-16 12:25:04.591: DEBUG/test(13526): assets
03-16 12:25:04.591: DEBUG/test(13526): classes.dex
03-16 12:25:04.591: DEBUG/test(13526): res
03-16 12:25:04.591: DEBUG/test(13526): resources.arsc
03-16 12:25:04.614: DEBUG/test(13526): Length of /assets is 0
03-16 12:25:04.637: DEBUG/test(13526): Length of /assets/ is 0
03-16 12:25:04.661: DEBUG/test(13526): Length of /assets/ is 0
03-16 12:25:04.692: DEBUG/test(13526): Length of ./assets/ is 0
03-16 12:25:04.716: DEBUG/test(13526): Length of ./assets is 0

I figured out that you can read from the assets directory without actually using the folder name:
InputStream is = assetManager.open("test.png");
I also tried this with an asset in Appliction 2 from Application 1, where the folder path is /asset/icon/image.png:
InputStream is = assetManager.open("icon/image.png");
Next I figured out that you can list a directory inside assets:
String[] list = assetManager.list("icons");
That also works great. The only thing failing right now is how to list the base directory assets.

View 3 Replies View Related

Android :: Webview Load Html From Assets Directory

Jun 30, 2010

I'm trying to load a html page from the assets directory. I tried this, but it fails. I don't really get any telling errors in LogCat...

View 1 Replies View Related

Android :: Play Audio From Stream / Stored Cache File

Feb 10, 2010

How to play audio from a stream in android? I will get input stream from an online link( like continuous FM). I need to cache the stream and play it. I searched a lot in sites,,,but didnt get.They show option of playing from a stored file. There is no option to play from a stream.

View 2 Replies View Related

Android :: Create Directory Or File Into Data / Local Directory?

Aug 5, 2010

I want to download my apk file into "/data/local/" directory. I am able do this in external storage but unable on "/data/local" also i was trying to create folder on same location but could not do that. Through "adb push" it is possible but i need to do this java program.

View 2 Replies View Related

General :: Play WhatsApp Audio AAC File?

Apr 6, 2014

i save whatsapp audio files ( .aac ) , but i cant' play them on pc or phone ...

View 2 Replies View Related

HTC Incredible :: Unable To Play This Type Of Audio File

Jun 4, 2010

I have an HTC incredible and have tried everything to put music on it, the most recent program i am using is tunesync, which works great. However, whenever i transfer music i always get the message "unable to play this type of audio file" I have tried everything from making the files all mp3 format to using different programs to do the sync, but nothing will work.

View 3 Replies View Related

General :: Play Audio File On Voice Call

Dec 17, 2011

I want to play an audio file on a voice call as following the application initiates a call from device X to device Y. When Y replies application on device X should inject an audio file in the stream of the call so device Y hears this audio file

Is possible to inject an audio file in the stream of the call/the output of microphone?

View 2 Replies View Related

General :: Can't Play Any Audio File And See Photos In Gallery

Aug 16, 2012

All apps that play audio files from my device can not find and play any of my songs and audio files that are in my device internal SDcard and I can not see my photos in the gallery.

View 4 Replies View Related

Android :: Resume Activity And Play Audio File After Spawned Thread Completes Download?

Jan 13, 2010

I've got an activity that calls a helper class called DownloadManager. DownloadManager spawns a thread that downloads a mp3 to the sdcard. I'm having some trouble finding the best design for resuming the initial activity and starting the MediaPlayer. Does it make the most sense to use a BroadcastReceiver that receives a message that download is complete, then start a new Intent of my activity? Think I saw something that I can't use an Intent to start an Activity from BroadcastReceiver because it is a background process.

View 4 Replies View Related

HTC Incredible :: Music Sync - Message Unable To Play This Type Of Audio File

Jun 4, 2010

I have an HTC incredible and have tried everything to put music on it, the most recent program i am using is tunesync, which works great. However, whenever i transfer music i always get the message "unable to play this type of audio file" I have tried everything from making the files all mp3 format to using different programs to do the sync, but nothing will work.

View 1 Replies View Related

Android :: Is There Way To Phone And Play Audio File In Android ?

May 5, 2009

I would like to create an ermergency call application : if triggered, it calls a given number and play an audio file, giving the information the caller couldn't give himself.For that I need to engage a call but ensure that I can replace any sound from the speaker with an played audio file. Can I do that in android ? What's the way?

View 1 Replies View Related

Android :: Play Mp4 Video From Assets Folder

Aug 21, 2010

I want to play mp4 video which is available in my assets/raw folder. I am successfully playing mp4 video from my sd card but not able to get video from assets folder or from raw folder.

View 1 Replies View Related

Android :: Play A Video From My Assets Or Raw Folder In App

Sep 19, 2010

I want to play a video from my assets or raw folder in my app in ANDROID using VideoView I am getting the error as video cannot be played.

Here is the code I used:

CODE:...................

View 1 Replies View Related

Android :: Writing To File Assets Folder

Nov 16, 2009

Can any one give the code to read and write to a file in the Android assets folder.

View 3 Replies View Related

Android :: Audio Record And Play Recorded Audio

Jun 2, 2009

Could you please let me know how to do the audio record in android emulator and play the same recorded audio. Could you please help me in proceeding in development.I tried with MediaPlayer API's also.Its not working.

View 5 Replies View Related

Android :: Error Creating MediaPlayer With Uri Or File In Assets

Jun 22, 2010

I copied song.mp3 to my project's assets directory and wrote this code:

private MediaPlayer mp;

Uri uri = Uri.parse("file:///android_asset/song.mp3");

mp=MediaPlayer.create(this, uri);

After running the create statement, the variable mp is null.

View 1 Replies View Related

Android :: Read A GZIP File In The ASSETS Folder

Mar 2, 2010

How can you read GZIP file in Android located in the "ASSETS" (or resources/raw) folder?

I have tried the following code, but my stream size is always 1.

GZIPInputStream fIn = new GZIPInputStream(mContext.getResources().openRawResource(R.raw.myfilegz));
int size = fIn.available();

For some reason the size is always 1. But if Idon't GZIP the file, it works fine.

Using Android 1.5

View 5 Replies View Related

Android :: Determining Filetype Of File In Assets Folder

Jun 9, 2010

Question: How do you programmatically distinguish between directories and regular files in the assets folder?

When using AssetManager to access files in the assets folder, it seems impossible to determine if a file is in fact a file or a directory. You get the list of files from the list method and then open the file using the open method. I thought perhaps using the openFd method to get the asset file descriptor (and then subsequently requesting the normal file descriptor) would provide me some information. But requesting the file descriptor for a directory results in an IOException (which makes sense since what would it mean for a directory to have a file descriptor...?).

Currently I'm relying on that IOException (resulting from attemptng to open a directory in the assets folder) in order to determine if a file is in fact a directory. (Opening a regular file works just fine). This seems like a bad idea. Any other suggestions to distinguish between a file and a directory?

View 1 Replies View Related

Android :: Check For File Existence In Assets Folder

Aug 28, 2010

My app has .txt files in subdirectories in the assets folder. It reads those .txt files and puts them in a textview. It's working great and no problems.

Should I be concerned about the files in the assets folder getting deleted by the user or missing. If this ever could happen, my app would get an error because the file would not be there when it tried to read it into the stream.

Is there a need for me to check the existence of an asset file before I read it or does the asset manager take care of it all? I also was wondering if there's a chance that a user would or could delete and asset file.

Like I say, everything works fine without me inserting code to check for file existence. I just wondered if people use the .exists() statement every time they go to read in a stream from assets.

View 2 Replies View Related

Android :: Better To Create Db / Tables Programmatically - Through A .db File In Assets?

Mar 2, 2010

Does Android have a "best practices" guideline on creating & populating the db/tables programmatically vs. deploying a .db file in assets?

What are the pros/cons of both approaches?

I have a db with big long strings in several columns, and about 50 rows, so writing the insert statements alone would take quite some space. It seems a waste.

View 2 Replies View Related

Android :: Accessing Assets Folder Sqlite Database File

Apr 9, 2010

How to read data from the assets folder sqlite database file with .sqlite extension in my Android application?

View 3 Replies View Related

Android :: Assets-Folder - Takes Always The First File By Alphabetical Order

Oct 17, 2010

I'm new in Java/Android programming, so please have patience with me.

I try to play a mp3 which is locate und the assets folder. I know there is another way with the /res/raw/ folder, but use the assets-folder because later I'll try to access the file by String.

This code works to play a mp3-file:

CODE:...............

Now the problem: In the same assets-folder is another mp3 file stored. Though I specify the name of the mp3 to use it take the one which comes first in alphabet. E.g. the other file is named "music.mp3" it plays this one. Renaming it to "worldmusic.mp3" it will play "song.mp3". Rerename "worldmusic.mp3" back to "music.mp3" it will take this mp3 again. Another test: Renaming "song.mp3" to something other so the application can find whats specify by the code above will result that no song is played. So this means the songname have to exist, although it take arbitrary the song first in alphabet.

I'm testing with the AVD emulator of eclipse. But I think the behaviour would be the same on a real device.

View 3 Replies View Related

Android :: Opening An Image File Inside The Assets Folder

Dec 19, 2009

I have a .gif file inside the assets folder like this assets/Files/android.gif. when I try to open the file it throws an exception at the second line.

CODE:...........

so is it that I'm trying to open an image file despite that the same code works if I try to open a text file?

View 3 Replies View Related

Android :: Analog To IOS Core Audio / Audio File Stream Services?

Sep 22, 2010

Is there an Android equivalent to the iOS Core Audio / Audio File Stream Services? I need to be able to read audio bytes from a network and feed them to the audio system under my control, so I can do my own timeouts / reconnects / range requests / etc. without interrupting the audio playback (since the system audio thread would be playing audio already enqueued). It seems that MediaPlayer doesn't give me this level of control. Is there a lower-level framework that does, either in the SDK or NDK?

View 2 Replies View Related

Motorola Droid : How To Play Audio From Phone Through RR Audio System?

May 5, 2010

I connected my phone via USB to my RR sport to upload audio files to the RR hard drive. However, I keep getting connection error. Apparently my device is not being recognized as a storage. I did the unmount thinking. Also, I am wondering how I can play audio from my phone through the RR audio system.
RR is 2010.

View 2 Replies View Related

Android :: Combine Only One Audio File From Two Audio Files

Oct 2, 2010

I want combine two audio files. (A audio file + B audio file = AB audio file)So, my search result is:

1. useing an AudioTrack.

2. decode PCM from audio file.

3. combine PCM.

This is currect? It there another way?

View 1 Replies View Related

Android :: Read LARGE Sqlite File To Be Copied Into Emulator - Or Device From Assets Folder

May 28, 2010

I guess many people already read this article:

Using your own SQLite database in Android applications: http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/comment-page-2/#comment-12368

However it's keep bringing IOException at

CODE:.............

I'am trying to use a large DB file. It's as big as >8MB. I built it using sqlite3 in Mac OS X, inserted UTF-8 encoded strings (for I am using Korean), added android_meta table with ko_KR as locale, as instructed above.

However, When I debug, it keeps showing IOException at

CODE:..............

I suspect it's caused by trying to read a big file. If not, I have no clue why.
I tested the same code using much smaller text file, and it worked fine.

Can anyone help me out on this? I've searched many places, but no place gave me the clear answer, or good solution. Good meaning efficient or easy.

I will try use BufferedInput(Output)Stream, but if the simpler one cannot work, I don't think this will work either.

Can anyone explain the fundamental limits in file input/output in Android, and the right way around it, possibly?

WITH MORE DETAIL:

CODE:...............

View 3 Replies View Related

HTC Incredible :: Trying To Play Music - Says Unable To Play This Type Of Audio

Apr 28, 2010

I took out the 8GB SD card from my Blackberry Storm and put it the Incredible.

I had a bunch of music saved on my SD Card that I downloaded from VZW Music Media thing.

When I go to music on the Incredible and go over the song (it shows the picture of the album of the song)

it says "unable to play this type of audio"

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved