android-mediaplayer

Mediaplayer error (-19 0) doesn't work with release()

こ雲淡風輕ζ 提交于 2019-12-12 03:55:47
问题 I'm coding a Soundboard and I got a problem when you have clicked 20+ times on the sounds. First I get MediaPlayer error(-19 0) and you can't hear any more sounds. I know it's my memory. So when I try to add Release(); it doesn't sound at all. Here is a button that plays sound: public void click7(View v) { MediaPlayer mp = MediaPlayer.create(NewActivity3.this, R.raw.hahah); mp.start(); } I have been trying with release as well then there's no sound: public void click7(View v) { MediaPlayer mp

Mediaplayer stops suddenly on playing

夙愿已清 提交于 2019-12-12 03:53:55
问题 I am new to android I have created a media player app but whenever i start playing it suddenly stops with an error as "Unfortunately youapp stopped". How should i rectify my app ? Pls help me here's the code : package com.example.allah; import java.util.ArrayList; import android.app.Activity; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; public class

In android, is there any way to play an audio in just during call beeps before the call is picked up by other person?

ⅰ亾dé卋堺 提交于 2019-12-12 03:44:44
问题 In my android app, before a call is picked up, I want to just replace the call beeps with an audio file? and once the call is picked up, I would turn off my audio file. Please someone help me out in this issue! P.S: The purpose of this feature is just to replace the annoying call beeps before the receiver on the other end picks up the call. 回答1: This person is playing an audio file during the call, please follow the link, My streaming audio player continues to play during a phone call -

how to speed up the forward/rewind process when button pressed continuously

牧云@^-^@ 提交于 2019-12-12 02:58:36
问题 I want to increase the forward/rewind speed if the button is pressed continuously. I created my customized media controller from here. What would be the good way to speed up the forward/rewind process? I got some idea form here. Finally I implemented it too but the touch event worked successfully in my emulator or and android mobile too but didn't worked for android stb. Other solutions rather than using it would be appreciated. 回答1: How about you monitor the MotionEvent.ACTION_DOWN and

Can't use MediaPlayer.create in new View.OnFocusChangeListener() in Android app

梦想与她 提交于 2019-12-12 02:37:15
问题 OK, I'm having an issue that I don't understand in my Android app. In the code below, I'm getting an error on the MediaPlayer mpWeight = MediaPlayer.create(this, R.raw.mppig) ; Holding my cursor over create says: The method create(Context, int) in the type MediaPlayer is not applicable for the arguments ( new View.OnFocusChangeListener(){}, int ) What does that mean, and more importantly, how do I resolve it? Here's the whole routine: TextView tv=(TextView)findViewById(R.id.weight); tv

android - overriding back button causes volume buttons stop working

给你一囗甜甜゛ 提交于 2019-12-12 01:58:46
问题 I'm trying to override Back button to stop an audio player and close media player activity, but I noticed that volume buttons are not working anymore. I imagine there is a mistake in overriding code. PS. in my MediaController I override hide() method to always show controls. mediaController = new MediaController(this) { @Override public void hide() { // TODO Auto-generated method stub //do nothing } @Override public boolean dispatchKeyEvent(KeyEvent event) { if(event.getKeyCode() == KeyEvent

enable vibrate mode in android apps

徘徊边缘 提交于 2019-12-12 01:54:12
问题 i m setting vibrate mode in my app so that when notification comes phone gets vibrated. I do see many apps uses different profiles like low, medium & high as option in vibrate mode. i know the way to use vibrate in android apps ie Vibrator vibrator; vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(3000); for different profiles, we need to set the time manually or any system defined standard way is there to use for vibrate option? 来源: https://stackoverflow.com

Android Media player wont work with checkbox?

允我心安 提交于 2019-12-12 01:26:09
问题 I have a song playing in the background, and on the next page is a check box. When it's checked I want the music to stay on and it when it's unchecked I want it to stay off. It works fine except for one way. When I uncheck the music while playing it stops the music as it should. now if I restart the app the music doesnt turn on which is good as well, but when I go to check music it doesnt turn back on until I go back to the previous page. i want to to start once it's rechecked. If the music

Need an if statement to stop MediaPlayer object only if it's playing

ぐ巨炮叔叔 提交于 2019-12-12 01:06:22
问题 I have created a timer, so that when it finishes, music plays. But the song does not ever stop playing if the user presses the back button. So I tried to override the lifecycle method onPause() , which worked, so if the timer had finished and the music was actually playing - then using the back button stopped the music. However, when a user tries to press the back button of their device before the timer finishes (and the music has not started yet), then I get a null pointer exception in the

MediaPlayer object getting Null after orientation change?

时间秒杀一切 提交于 2019-12-12 00:26:01
问题 I am trying to do video streaming that is working fine in portrait mode. Then I added code for onConfigurationChange to inflate another layout for landscape mode. but my app is getting crashed at this line: int timeElapsed = mediaPlayer.getCurrentPosition(); Here I am getting mediaPlayer as null while it has been already initialized. MediaPlayer mediaPlayer; public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detailvideo