android-mediaplayer

Android's MediaPlayer setSurface while on paused state

喜夏-厌秋 提交于 2019-12-12 08:49:52
问题 EDIT : So apparently this has nothing to do with multiple activities, and this has something to do with the encoding of the video file. I will try to simplify the question: I have a MediaPlayer object in a paused state, when I call mediaPlayer.getCurrentPosition() I get a result which is accurate. When I call mediaPlayer.setSurface() (using a different surface) followed by mediaPlayer.play() on this object the video is played in a different position than the one returned by getCurrentPosition

How to display lyrics as per song playing in android? [closed]

删除回忆录丶 提交于 2019-12-12 08:15:00
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I would like to create music player, with a textView displaying lyrics of MP3 being played. The lyrics should displayed in sync with music. I want to know that how to get lyrics and for display the text I refer this example. Any suggestions on how I can do this? I am stuck in this

How to Pause and Resume Audio recording in android

こ雲淡風輕ζ 提交于 2019-12-12 08:09:44
问题 I am developing an audio recording application using MediaRecorder class. I have the following requirement: 1.When a pause button is pressed then pause recording. 2.When a resume button is pressed then resume recording where it paused. I try this link But I am unable to implement the functionality. Any help/suggestion would be greatly appreciated. 回答1: Media Recorder class does not support to pause and resume , see second link class overview try to use stop and restart How can i pause voice

Play sound through earpiece when using MediaPlayer

对着背影说爱祢 提交于 2019-12-12 06:20:06
问题 I am playing voicemail recordings in my app. The way I currently have it set up, it plays the voicemail through the speakerphone. What is the best way to be able to toggle between speakerphone and earpiece. Here is how I set up my MediaPlayer: mediaPlayer = new MediaPlayer(); mediaPlayer.setOnPreparedListener(this); mediaPlayer.setOnCompletionListener(this); mediaPlayer.setOnErrorListener(this); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mediaPlayer.setDataSource(url); }

how to pause media player sound in android

别说谁变了你拦得住时间么 提交于 2019-12-12 05:59:25
问题 I have media player in main activity. And sound start with this activity. I want when new activity start audio stop and when I press back from next activity and back to main activity audio starts. Please help me. Code- @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mp = MediaPlayer.create(this, R.raw.test); mp.start(); mp.setLooping(true); addListenerOnButton(); } public void addListenerOnButton() { boy1 =

Why does this code take a long time?

懵懂的女人 提交于 2019-12-12 05:13:49
问题 I am using this following code for getting all songs stored in the sdcard. https://stackoverflow.com/a/12227047/2714061 Well why does this code take so long to return this list of songs. I have included this code in a function which is called from the oncreate method in my player's playlist. This is what happens. 1: When the application runs is executed for the first time on my android ph, the playlist has nothing to show, and hence is seen empty. 2: Well after for instance-> 30sec when I

Accessing image of the last clicked item in listview

一世执手 提交于 2019-12-12 04:53:09
问题 Below is the code for the listview adapter which displays list of tracks.Each list item has play and stop icons to play and stop track.When user clicks on play image button it changes to pause button image and track starts playing..When I click on pause button image it changes to play button image and track stops playing.While playing a track if I click on another track play image button previous track stops and the current clicked track start playing but the issue is that previous track

How to play recorded audio file from 'onActivityResult()'?

二次信任 提交于 2019-12-12 04:35:50
问题 I'm using this library to record audio in my app. Here's my code: recordDefectAudio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ContextCompat.checkSelfPermission(getBaseContext(), android.Manifest.permission.RECORD_AUDIO) + ContextCompat.checkSelfPermission(getBaseContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(MainActivity.this, new String[]{android.Manifest

One public media player class to be used across all activities

心不动则不痛 提交于 2019-12-12 04:34:25
问题 Updated. After the recommendations, I decided to run media player in a new thread. Because I need Media Player only when activities are on the screen. Here is the new code: First, my public SingleMP (Media Player) class used in multiple classes: import android.content.Context; import android.media.MediaPlayer; import android.net.Uri; public class SingleMP implements Runnable { public static MediaPlayer mp; private static Context context; private static Uri uri; public SingleMP(Context context

Unable to play YouTube Videos

孤街醉人 提交于 2019-12-12 04:04:51
问题 Please have a look at the following code private class IntroVideoHandler implements OnClickListener { @Override public void onClick(View arg0) { // TODO Auto-generated method stub MediaPlayer mp = new MediaPlayer(); try { mp.setDataSource("http://www.youtube.com/watch?v=Cb7QJwQ58T0"); mp.prepareAsync(); mp.start(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } Here, I am unable to play the youtube video either in simulator or phone. I get the following