android-mediaplayer

What means the message “internal/external state mismatch corrected” at the MediaPlayer?

主宰稳场 提交于 2019-12-10 22:05:15
问题 I work with a MediaPlayer and set the state of the player often programmatically like for example: if(mp.isPlaying()) { mp.pause(); animationPausedMusic(); } private void animationPausedMusic() { // Changing button image to play button btn_play.setBackgroundResource(R.drawable.play); ... // more code } But sometimes the logcat gives me the message: "internal/external state mismatch corrected" And then the play and pause function is not working anymore. What does this message mean? And how can

Android MediaPlayer: video seek causes onSeekComplete to be called twice

拜拜、爱过 提交于 2019-12-10 21:25:19
问题 What am I doing wrong here? I set up onSeekCompleteListener, I prepare a movie, I do a seek. Right away onSeekComplete is called. Then after a delay I play the movie. And then onSeekComplete is called again! Why again? Here is my code: package com.test.seek; import java.io.IOException; import android.app.Activity; import android.media.MediaPlayer; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.util.Log; import android.view.SurfaceHolder; import

How to play a lot of sounds in background of an activity?

心不动则不痛 提交于 2019-12-10 19:04:24
问题 For example, I want to play 3 songs. When the 1st song ends, the 2nd song begins, and when the 2nd song ends, the 3rd song begins, and when the 3rd song ends, the 1st song begins again and so on. Is the mp.setOnCompletionListener used here? 回答1: You are right. You can do something simple like this: public class MainActivity extends Activity { MediaPlayer mp1, mp2, mp3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mp1 = MediaPlayer.create

Android MediaPlayer Error (1,-22)

橙三吉。 提交于 2019-12-10 17:29:56
问题 Error (1,-22) occurs after long playing (about hour or more) the same track in a loop. I can't figure out the reason of that error. Everything is okay if track is playing for short time. But if I keep track playing for long time in my Service , sometimes the error happens. I know that 1 is MEDIA_ERROR_UNKNOWN , but cant find anything about -22. Any suggestions? API 24 回答1: It seems to issue appears because I didn't call MediaPlayer.release() when onCompletion callback. As a result resources

Android: MediaPlayer setVolume function not working

此生再无相见时 提交于 2019-12-10 17:12:28
问题 I am trying to play sound via media player on STREAM_SYSTEM using mediaPlayer.setVolume(1.0f , 1.0f); or mediaPlayer.setVolume(0.90f , 0.90f); But it is playing on vol as per Hardware volume controls in settings. Basically this line has no effect. I have added permissions "Modify..." as well in Manifest But i saw links in stackoverflow where this API works. I don't wanna go to API AudioManager.setStreamVol().... as it sets stream vol for all apps What is problem that this setVol API is not

media player does not load when activity is recreated on orientation change

大兔子大兔子 提交于 2019-12-10 16:54:37
问题 I am new to play a video in video player using surface view now i want to save instance state of media player when orientation change when view reloaded or recreated then old media player state start at old position not to load on original means at zero position i set in manifest like screen orientation but that time oncreate not called i want to call also oncreate method when screen orientation change means to say i want to reload a new activity when orientation change and also save media

Android MediaPlayer not playing sound on some devices

淺唱寂寞╮ 提交于 2019-12-10 16:48:36
问题 I have made a simple alert beep for my application. But the problem is that the sound is played on some devices and in some others not. The sample code below: public void audioPlayer() { // leshon tingull kur ka kolision //Armando 8/7/2013 MediaPlayer beep_alert = MediaPlayer.create(Maps.this,R.raw.double_beep); try { beep_alert.start(); } catch (Exception e) { e.printStackTrace(); } } There is no error shown, it just don play for example nexus 4 , but it plays ok in nexus 7 . What is going

Does Android VideoView cache streamed videos?

对着背影说爱祢 提交于 2019-12-10 16:29:46
问题 It looks like VideoView/Mediaplayer have no automatic caching. Is it just me? Does Android VideoView cache streamed videos? Or does it download it again for every playback? 回答1: There's no cache. You can insert a proxy server into the mix and cache it yourself if you need it. 来源: https://stackoverflow.com/questions/19515483/does-android-videoview-cache-streamed-videos

Android - Equalizer usePreset not working (No change in sound effect)

痞子三分冷 提交于 2019-12-10 16:18:11
问题 I am working on streaming radio application. everything is working fine except the changing the equalizer effect does not affect sound. Changing the equalizer effect by calling usePreset(preset) does not make any changes in the sound effects. Even though there is no error, why usePreset does not change the sound effects. I have tested in samsung galaxy sII with 4.0.3. public void startPlayer() { // // Check whether we can acquire the audio focus // to start the player // if (

MediaPlayer is not looping

僤鯓⒐⒋嵵緔 提交于 2019-12-10 15:48:41
问题 I want to create activity background music, but MediaPlayer playing not repeatedly :( Why my MediaPlayer is not looping? There is my code: MediaPlayer mediaPlayer; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.tersetetete); mediaPlayer = new MediaPlayer(); mediaPlayer.setVolume(8f, 8f); mediaPlayer.setLooping(true); mediaPlayer = MediaPlayer.create(this, R.raw.fon);