android-mediaplayer

Android media player: streaming audio file from HTTPS Url

自古美人都是妖i 提交于 2021-02-07 04:17:01
问题 I have to stream an audio file from Android media player from an application. Initially the file to be streamed was coming from a Http:// url and for which I was Using code- public void playSample() { AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { mediaPlayer = new MediaPlayer(); } @Override protected Void doInBackground(Void... arg0) { try { try { mediaPlayer.setDataSource("http://an.http.url/"); mediaPlayer.prepare();

Android media player: streaming audio file from HTTPS Url

别来无恙 提交于 2021-02-07 04:15:17
问题 I have to stream an audio file from Android media player from an application. Initially the file to be streamed was coming from a Http:// url and for which I was Using code- public void playSample() { AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { mediaPlayer = new MediaPlayer(); } @Override protected Void doInBackground(Void... arg0) { try { try { mediaPlayer.setDataSource("http://an.http.url/"); mediaPlayer.prepare();

Find out which Music is currently playing [Android]

徘徊边缘 提交于 2021-02-06 12:55:50
问题 Is there a way to find out which music is currently playing in the android Music player ? So I want to catch the title time and maybe the author of this music and show it with Textview. Is this possible ? 回答1: In concordance with the Android API here: AudioManager should be what you are looking for You can create an AudioManager and then call the isMusicActive to retrieve a boolean if it is playing. You can then use the MediaPlayer API and call the getTrackInfo method which returns an Array

Android mediaPlayer.getDuration() return 0 or -1

烈酒焚心 提交于 2021-02-05 09:23:07
问题 I am creating online media player where we are playing song with the help of URL . In Media Player we are displaying Total time of song, for displaying time we are using mediaPlayer.getDuration() function but it always returning -1 . When I am passing Drop Box URL then it working but when I pass my server URL (https://) then it not working. 2021-01-25 14:50:33.777 11438-11438/com.dd.xyz W/MediaPlayer: Use of stream types is deprecated for operations other than volume control 2021-01-25 14:50

MediaRecorder stop() failed

谁都会走 提交于 2021-01-29 11:05:22
问题 I know there are a few of these on SO already but none of them really were able to help my issue, but when I am running the code and start recording audio and then press my stop button it always fails because it is in the wrong state. I am not sure how I would go about fixing my states for this. Here is my MainActivity.java code: import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content

Android MediaDataSource unexpected behavior

强颜欢笑 提交于 2021-01-07 02:39:18
问题 i was trying to play AAC audio stream in android MediaPlayer, as mentioned here and also here author claimed the problem was ignoring position argument so i made a little setup to test this i will record using recorder and save it to a buffer and feed this buffer to MediaPlayer according to this // parcel pipe: 1: write // 0: read ParcelFileDescriptor[] pfd = ParcelFileDescriptor.createPipe(); // a Good Recorder! final MediaRecorder mMediaRecorder = new MediaRecorder(); mMediaRecorder

Android MediaDataSource unexpected behavior

99封情书 提交于 2021-01-07 02:37:36
问题 i was trying to play AAC audio stream in android MediaPlayer, as mentioned here and also here author claimed the problem was ignoring position argument so i made a little setup to test this i will record using recorder and save it to a buffer and feed this buffer to MediaPlayer according to this // parcel pipe: 1: write // 0: read ParcelFileDescriptor[] pfd = ParcelFileDescriptor.createPipe(); // a Good Recorder! final MediaRecorder mMediaRecorder = new MediaRecorder(); mMediaRecorder

How to pause and play media player when screen is locked or sleeps?

不羁岁月 提交于 2021-01-01 13:55:52
问题 I am using Java and xml to create an application for the summer. This app has music in the background, that I would like to pause and then play depending on the state it is in. When i lock my screen the music does not pause it keeps playing. How would i fix this, I have tried to use the method on this site: https://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents I have not been able to successfully get a working prototype, and I am working in android studio.

How to pause and play media player when screen is locked or sleeps?

℡╲_俬逩灬. 提交于 2021-01-01 13:55:07
问题 I am using Java and xml to create an application for the summer. This app has music in the background, that I would like to pause and then play depending on the state it is in. When i lock my screen the music does not pause it keeps playing. How would i fix this, I have tried to use the method on this site: https://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents I have not been able to successfully get a working prototype, and I am working in android studio.

How to pause and play media player when screen is locked or sleeps?

帅比萌擦擦* 提交于 2021-01-01 13:51:50
问题 I am using Java and xml to create an application for the summer. This app has music in the background, that I would like to pause and then play depending on the state it is in. When i lock my screen the music does not pause it keeps playing. How would i fix this, I have tried to use the method on this site: https://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents I have not been able to successfully get a working prototype, and I am working in android studio.