I want to make a application in which i play the .mp3 file
i play the sound by selecting it from raw or asset folder which is hard coded in code.
But i want that user pick any mp3 file anywhere from their android phone and make play it
Can any one help me
Thanks in advance
MediaPlayer mediaPlayer= MediaPlayer.create(this, R.raw.song);
mediaPlayer.start();
int duration = mediaPlayer.getDuration();
int current_position = mediaPlayer.getCurrentPosition();
mediaPlayer.pause();
Great tutorial on Media Playback through MediaPlayer:
http://www.tutorialspoint.com/android/android_mediaplayer.htm
Related
i am trying to play music or mp3 on click of an action button but none is working since most of the tutorials are based on button listeners. i need help regarding how to play music on click of an option menu or action bar menu. Can anyone please help me regarding this problem.
Here is a recommended solution to playing a mp3:
Link: Simple mediaplayer play mp3 from file path?
String filePath =
Environment.getExternalStorageDirectory()+"/yourfolderNAme/yopurfile.mp3";
mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(filePath);
mediaPlayer.prepare();
mediaPlayer.start()
and this play from raw folder.
int resID=myContext.getResources().getIdentifier(playSoundName,"raw",myContext.getPackageName());
MediaPlayer mediaPlayer = MediaPlayer.create(myContext,resID);
mediaPlayer.prepare();
mediaPlayer.start();
I want to make a music player that can play all music on my memory card.
I use this code for play a music, but i can't play music from memory card, only in raw folder.
MediaPlayer mp = MediaPlayer.create(this, R.id.raw.audio.mp3)
what I should do, so i can play music from SD card ?
You'll want to do something like this
Uri song = Uri.parse(location-of-song); //location-of-song is where the music is on the sd card
mPlayer = new MediaPlayer();
mPlayer.setDataSource(getApplicationContext(), song);
mPlayer.start();
Use the version of create that takes a URI, and provide a URI to the local file you want to play.
I want to play a "wav" file of 1 seconds multiple times without gap. All my attemps failed.
My existing code is as follows;
MediaPlayer mMediaPlayer = MediaPlayer.create(this, R.raw.my5s);
MediaPlayer mMediaPlayer2 = MediaPlayer.create(this, R.raw.my5s);
mMediaPlayer.setVolume(1, 1);
mMediaPlayer.setLooping(true);
this.mMediaPlayer.setNextMediaPlayer(mMediaPlayer2);
this.mMediaPlayer.start();
I also tried the solutions in the following links;
play .ogg file
manual looping
Add this to program
mMediaPlayer.perpare();
I have image is my Draw able folder.When I call this image I want to play an audio also which is in my raw folder.can I do this how??please help me.
You can achieve by creating image button and put image on it. and onClick of that button you can play the music using MediaPlayer api.
Refer this : http://developer.android.com/guide/topics/media/index.html
Example code for Play audio from Raw folder
: http://www.barebonescoder.com/2010/06/android-development-audio-playback-safely/
you can write this code at onResume:
MediaPlayer mp = MediaPlayer.create(getApplicationContext(),
R.raw.name);
mp.start();
while (mp.isPlaying()) { // donothing
}
;
mp.release();
how do i display videos retrieved from resources in my android application ?
MediaPlayer mp = new MediaPlayer();
mp = MediaPlayer.create(context, R.raw.vid);
mp.start();
i have placed a vid.3gp file in my res/raw folder..
i am getting NullPointerException.. what changes do i need to make
why so??
do we need something called as Surface Holder or something similar ?
using the MediaPlayer you should be able to play video