Skip to main content

Posts

Showing posts with the label play audio

Play audio from sdcard programatically in android

Media Player example in android /how to play audio in android/play song from sdcard programmatically in android The Android multimedia framework includes support for playing variety of common media types, so that you can easily integrate audio, video and images into your applications. You can play audio or video from media files stored in your application's resources (raw resources), from standalone files in the filesystem, or from a data stream arriving over a network connection, all using   MediaPlayer APIs. In  this example, I’ll show you a simple program to play an audio file from sdcard. To play an audio file, first create an object of media player class MediaPlayer mp3=new MediaPlayer(); Then set path of file Mp3.setDataSource(“sdcard/filename.mp3”); Before playing audio, call prepare Mp3.prepare(); To play audio ,call Mp3.start(); To pause, call Mp3.pause To stop audio, call Mp3.stop();   main.xml <? xml version = "1.0" encoding = "utf-8" ?> &