Click here to Skip to main content
13,141,576 members (53,538 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 17 Apr 2013

Android: Play Media File in the Assets Folder

, 17 Apr 2013
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 --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170915.1 | Last Updated 17 Apr 2013
Article Copyright 2013 by Yildirim Kocdag
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid