media-player

How to support MOV(quick time) in android?

半腔热情 提交于 2019-12-01 15:45:20
I want to play in .mov file in android. But videoview or mediaplayer doesn't support this meida format. How can i add the support to it? In general Android doesn't support any other media formats than the one listed here . That being said, there are quite a few 3rd party players that enable playback of more exotic formats, most of which are probably based around ffmpeg. You might want to take a look at the open source Dolpin Player (actual player also available in the Play store ) for Android for some more pointers - not sure if mov playback is supported by default though. However, since most

Check if music playing in android media player API

一世执手 提交于 2019-12-01 15:23:31
I'm using this code below to play an audio file in android MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setDataSource("fileSourceHere"); mediaPlayer.prepare(); mediaPlayer.start(); I have a button on that program. When click on that button, it'll check if music playing. If music playing, it'll stop that. How can I check if music playing? I tried the code below but it didn't work if(mediaPlayer.isPlaying() == true){ mediaPlayer.pause(); }else{ mediaPlayer.start(); } Try this: MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setDataSource("fileSourceHere"); mediaPlayer

Android Media Player Restart Audio After Calling Stop

 ̄綄美尐妖づ 提交于 2019-12-01 15:17:26
I'm able to stream audio and stop it without any problem, but when I try to start it again after stop, it doesn't start and I get an IllegalState exception. Here is what I'm doing: Start Playing mediaPlayer.setDataSource(PATH); mediaPlayer.prepare(); mediaPlayer.start(); Stop Playing mediaPlayer.stop Now, if I want to start playing again the same media, what will I have to do? *PATH is the URL of a continuous running radio station. Add this: mp.reset(); mp.setDataSource(MEDIA_PATH); mp.prepare(); mp.start(); In case you don't have access to the data source in the current scope, you can do: mp

Android MediaPlayer prepare failed: status = 0x1

£可爱£侵袭症+ 提交于 2019-12-01 14:45:11
问题 I'm building an audio recorder that needs to play back the recorded sound. I'm running into a lot of trouble playing back the audio. I know that the file exists because I isolated it into a folder on my SD Card, but for some reason it can't play it back. Here is my code: public class RecorderEditActivity extends SherlockActivity implements DatabaseHelper.MetadataListener { private long position; private Button playButton = null; private TextView date = null; private EditText title = null;

MediaPlayer pause doesnt work in android

情到浓时终转凉″ 提交于 2019-12-01 14:37:11
I use the following code to pause the play of an audio file. but it doesn't pause. What is wrong with the code. Any suggesstion... boolean play=false; int flag=0; mPlay.setOnClickListener(new OnClickListener() { public void onClick(View v) { mPlayer = new MediaPlayer(); if(play==false) { flag++; if(flag==1) { playAudio(); } else { mPlayer.start(); } mPlay.setText("Pause"); play=true; } else if(play==true) { mPlayer.pause(); mPlay.setText("Play"); play=false; } mPlayer.setOnCompletionListener(new OnCompletionListener() { public void onCompletion(MediaPlayer mp) { // TODO Auto-generated method

Mediaplayer and delay in playing

陌路散爱 提交于 2019-12-01 14:19:26
I create small application which is media player. I have method where I have a song. I want to delay playing sound after I clicked a button. How I can do this delay. I want to click on the button and after 5 seconds music is playing. I am using: MediaPlayer.create to get song and mediaplayer.start() to start playing, but I don;t know how I can delay start playing my song. Use a Handler in your Activity to delay events such as starting the mediaplayer in your case: private RefreshHandler mRedrawHandler = new RefreshHandler(); private RefreshHandler mRedrawHandler = new RefreshHandler(); class

Check if music playing in android media player API

孤人 提交于 2019-12-01 14:16:59
问题 I'm using this code below to play an audio file in android MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setDataSource("fileSourceHere"); mediaPlayer.prepare(); mediaPlayer.start(); I have a button on that program. When click on that button, it'll check if music playing. If music playing, it'll stop that. How can I check if music playing? I tried the code below but it didn't work if(mediaPlayer.isPlaying() == true){ mediaPlayer.pause(); }else{ mediaPlayer.start(); } 回答1: Try this:

WPF MediaPlayer: How to play in sequence, sync?

我怕爱的太早我们不能终老 提交于 2019-12-01 12:37:43
问题 I have this function: public static void Play(string FileName, bool Async = false) { System.Windows.Media.MediaPlayer mp = new System.Windows.Media.MediaPlayer(); mp.Open(FileName.ToUri()); mp.Play(); } When i call Play(@"file1.mp3"); Play(@"file2.mp3"); Play(@"file3.mp3"); Play(@"file4.mp3"); all them play at same time. How can i make MediaPlayer wait the end of the file, to play the next? What the function should like? EDIT: public static void Play(Uri FileName, bool Async = false) {

MediaPlayer pause doesnt work in android

↘锁芯ラ 提交于 2019-12-01 12:07:34
问题 I use the following code to pause the play of an audio file. but it doesn't pause. What is wrong with the code. Any suggesstion... boolean play=false; int flag=0; mPlay.setOnClickListener(new OnClickListener() { public void onClick(View v) { mPlayer = new MediaPlayer(); if(play==false) { flag++; if(flag==1) { playAudio(); } else { mPlayer.start(); } mPlay.setText("Pause"); play=true; } else if(play==true) { mPlayer.pause(); mPlay.setText("Play"); play=false; } mPlayer.setOnCompletionListener

Running a thread for some seconds

杀马特。学长 韩版系。学妹 提交于 2019-12-01 11:54:34
问题 I am using a media player instance to play a music file.I want to play the song for certain time then stop playing.I'm using a thread with counter decrementing but some how tis not workin properly. 回答1: you have to use handler for that try this in your onCreate use this //start media player mp.start(); mTimer.sendMessageDelayed(new Message(),5*10000); create a class in you activity class as private MusicTimer mTimer = new MusicTimer(); private class MusicTimer extends Handler { @Override