android-mediaplayer

Update MediaPlayer Start Position When Paused

こ雲淡風輕ζ 提交于 2020-07-18 09:21:20
问题 I am streaming live audio and wish to have the functionality to pause the mediaplayer and then start from the current live position. The default Pause() and Start() just starts from where it was stopped. Any ideas on how to keep the current position updated so that Start() is instant? 回答1: Did you try calling seekTo()? You could keep it pemanently updated by calling seekTo() every half a second or so with TimerTask, But i don't know how i feel about this. EDIT: If you call seekTo() every 500

Playing audio file from Firebase storage in android MediaPlayer

两盒软妹~` 提交于 2020-06-28 04:05:23
问题 I'm trying to play audio file from Firebase storage in my application. I wrote code exactly same from the youtube video about this, but it doesn't play a song. Can anybody tell what is the problem? I tried pretty many solutions in some questions such as missing permission in Manifest, relocation of MediaPlayer methods etc. Nothing worked. public void play_Song(View view) { final MediaPlayer mediaPlayer = new MediaPlayer(); try { mediaPlayer.setDataSource( url ); mediaPlayer.prepare();

How to evolve a seekbar from the place where media player has been paused?

喜你入骨 提交于 2020-05-17 06:56:41
问题 I have in connection a seekbar and a button alone used for play / pause. the principle is functional, when i press the button, it starts to play and in a second time when i press it pauses mediaplayer (perfect). The problem is when I press again so that it continues reading, the reading starts again from the beginning instead of continuing from the place where it had been paused. Please direct me, here is my code : PLAY_SONG private void play_songs() { mediaPlayer = new MediaPlayer(); if

Android media player exception timed out after 10 seconds

萝らか妹 提交于 2020-05-15 01:57:09
问题 have set of mp3 in raw file read them and set them in to an array get the array size generate a random number and pass that to media player as the element so player runs mp3 clips are less than 2 seconds so i wait 2 seconds and play the next clip and kind of a loop this needs to run till i stop this is the idea here is the code package com.hello.musicplayer; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.Timer;

Android media player exception timed out after 10 seconds

做~自己de王妃 提交于 2020-05-15 01:56:16
问题 have set of mp3 in raw file read them and set them in to an array get the array size generate a random number and pass that to media player as the element so player runs mp3 clips are less than 2 seconds so i wait 2 seconds and play the next clip and kind of a loop this needs to run till i stop this is the idea here is the code package com.hello.musicplayer; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.Timer;

Record audio and play it afterwards

戏子无情 提交于 2020-03-06 02:38:48
问题 I wrote a class that shall make it possible to record an audio, save it to the sd card and then play the result. Here is my code: public void recordAudio(final String fileName) { final MediaRecorder recorder = new MediaRecorder(); recorder.reset(); ContentValues values = new ContentValues(3); values.put(MediaStore.MediaColumns.TITLE, fileName); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder

Save uri to sharedPreferences and play with mediaplayer

别说谁变了你拦得住时间么 提交于 2020-02-28 05:09:50
问题 This is the code I use to save the string representation of the Uri to the SharedPreferences: public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQ_CODE_PICK_SOUNDFILE && resultCode == Activity.RESULT_OK){ if ((data != null) && (data.getData() != null)){ SharedPreferences sharedPref = getSharedPreferences("customName", Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit();

How do you play audio file sequentially in Java?

╄→尐↘猪︶ㄣ 提交于 2020-02-25 02:38:26
问题 So for an app I'm developing I have a bunch of audio files that, depending on the state of some variables, may or may not play (and the order in which they play can change as well). I understand the basics of the setOnCompletionListener , but I can't figure out the best way to use it. As of right now, if I want to play audio1, audio2, then audio3, my code is set up as follows: clipSetup(1); aP.setOnCompleteListener(new MediaPlayer.OnCompletionListener(){ @Override public void onCompletion

android - how to delay an audio file by a few seconds

强颜欢笑 提交于 2020-02-07 08:57:25
问题 I'm trying to figure out how to delay an audio file by about 15 seconds. The audio file is 5 seconds long and it's a sound effect saying "5,4,3,2,1 go!", the countdown is from 20 so it should start after 15 seconds. I heard I can do this with a handler but I don't know how to implement it in the code, so here it is, help would be much appreciated! I edited it with the way below, however now the player doesn't start at all, here's the new code: public class WorkoutGymEasy1 extends Activity {

Nodejs, Android - Video Streaming

大城市里の小女人 提交于 2020-02-07 06:01:06
问题 I am working on an application which displays videos from Nodejs& MongoDB server. The problem here is because the videos are not streaming, mediaPlayer on Android fully downloads video and then displays it and this is really slow as you can guess. I am not a native speaker so reading documents mostly hard to understand for me. Which path should I go? RTSP or HTTP streaming. Any tips how can I achieve my goal? All your help is appreciated, best regards. 回答1: While dedicated streaming servers