Click here to Skip to main content
11,806,931 members (64,116 online)
Click here to Skip to main content

Tagged as

Android: Play Media File in the Assets Folder

, 17 Apr 2013 CPOL 12.1K 3
Rate this:
Please Sign up or sign in to vote.
Play a media file (wav, MP3, etc) in the Assets folder.


Play a media file (wav, MP3, etc) in the Assets folder.

Using the code

You can write an application using the code that plays a media file which is stored in your Assets folder.

Play a Media File in Assets Folder

public void Play(String fileName)
    AssetFileDescriptor descriptor = _context.getAssets().openFd(fileName);
    long start = descriptor.getStartOffset();
    long end = descriptor.getLength();
    MediaPlayer mediaPlayer=new MediaPlayer();
    mediaPlayer.setDataSource(descriptor.getFileDescriptor(), start, end);


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Yildirim Kocdag
Turkey Turkey
Phd. Yildirim Kocdag is a Computer Engineer.

Programming Languages
Android, Objective-c, c#,,, javascript, TSQL.

Computer Science
DataMining, Compilers, Expert Systems, Digital Image Processing, AI and Extreme Programming.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151002.1 | Last Updated 17 Apr 2013
Article Copyright 2013 by Yildirim Kocdag
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid