Android mediaplayer error -38 0

android mediaplayer error -38 0

androidandroid-mediaplayer. I need your help. I tried to play an audio file stored in Assets folder but an error occurred. Here are my code. Android MediaPlayer error with intent and button Basically I have my main activity that, anycodings_button through a. After mediaPlayer.setDataSource(), you need to call prepare() to start(), otherwise an error will be reported, but when we play online audio, we should use. android mediaplayer error -38 0

Similar video

Android : Android MediaPlayer error (1, -2147483648)

Best Java code snippets using android.media.MediaPlayer$OnErrorListener.onError(Showing top 20 results out of 315)

@Test publicvoid testErrorListenerCalledNoOnCompleteCalledWhenReturnTrue() { Mockito.when(errorListener.onError(mediaPlayer, 112, 221)).thenReturn(true); shadowMediaPlayer.invokeErrorListener(112, 221); assertThat(shadowMediaPlayer.getState()).isEqualTo(ERROR); Mockito.verify(errorListener).onError(mediaPlayer, 112, 221); Mockito.verifyZeroInteractions(completionListener); }
@Test publicvoid testErrorListenerCalledOnCompleteCalledWhenReturnFalse() { Mockito.when(errorListener.onError(mediaPlayer, 0, 0)).thenReturn(false); shadowMediaPlayer.invokeErrorListener(321, 11); Mockito.verify(errorListener).onError(mediaPlayer, 321, android mediaplayer error -38 0, 11); Mockito.verify(completionListener).onCompletion(mediaPlayer); }
@Test publicvoid testPendingEventsRemovedOnError() { Mockito.when(errorListener.onError(mediaPlayer, 2, 3)).thenReturn(true); shadowMediaPlayer.setState(PREPARED); mediaPlayer.start(); scheduler.advanceBy(200); assertThat(scheduler.size()).isEqualTo(1); shadowMediaPlayer.invokeErrorListener(2, 3); assertThat(scheduler.advanceToLastPostedRunnable()).isFalse(); Mockito.verifyZeroInteractions(completionListener); }
@Override publicboolean onError(MediaPlayer mp, int framework_err, android mediaplayer error -38 0, int impl_err) { Logger.e("[VideoView]Error:" + framework_err + "," + impl_err); mCurrentState = STATE_ERROR; if (mOnErrorListener != null) mOnErrorListener.onError(mp, framework_err, impl_err); returntrue; } };
@Override publicboolean onError(MediaPlayer mp, int framework_err, int impl_err) { mCurrentState = STATE_ERROR; if (mOnErrorListener != null) mOnErrorListener.onError(mp, framework_err, impl_err); returntrue; } };
@Override publicboolean onError(MediaPlayer mp, int framework_err, int impl_err) { mCurrentState = STATE_ERROR; if (mOnErrorListener != null) mOnErrorListener.onError(mp, framework_err, impl_err); returntrue; } };
@Override publicboolean onError(MediaPlayer mp, int what, int extra) { 150 30 error adobe photoshop isErrorHappen = true; if (mErrorListener != null){ return mErrorListener.onError(mp, what, android mediaplayer error -38 0 } returnfalse; }
@Override publicboolean onError(MediaPlayer mp, int what, int extra) { if (null != mOnErrorListener) { mOnErrorListener.onError(mp, what, extra); } returnfalse; }
@Override publicboolean onError(MediaPlayer mp, int what, int extra) { Log.d(TAG, "onError called - " + what + " - android mediaplayer error -38 0 + extra); stopLoading(); this.currentState = State.ERROR; if (this.errorListener != null) returnthis.errorListener.onError(mp, android mediaplayer error -38 0, what, extra); returnfalse; }
@Override publicboolean onError(MediaPlayer mp, int what, int extra) { NoPlayerLog.d("Error: " + what + "," nss error on navisailor 4000 ecs extra); currentState = PlaybackState.ERROR; MediaPlayer.OnErrorListener onErrorForwarder = forwarder.onErrorListener(); if (onErrorForwarder == null) { thrownew IllegalStateException("Should bind a OnErrorListener. Cannot forward events."); } return onErrorForwarder.onError(mediaPlayer, what, extra); } };
@Override publicboolean onError(MediaPlayer mp, int what, int extra) { boolean handled = false; for (MediaPlayer.OnErrorListener listener : listeners) { handled = listener.onError(mp, what, extra)

[

I’m working on a that plays a song picked from an .
The problem comes when I use and methods, so here’s the code:

LOG:

How can I solve it?

,

Finally solved it! After a lot of trial & error!!
This is the line that causes it for me:

The API doc for setAudioSessionId doesn’t indicate any alternative or any issue on still using it which made it hard to debug. But I saw setAudioStreamType just below it, which is deprecated and suggests setAudioAttributes instead, w/c is added in API 21.

So I changed the above code to this:

And now it works!

By the way, as you can see, I checked only against version N (API 24) and above instead of from LOLLIPOP even though was added in API 21, because I only encounter this issue on Nougat devices, works up to Marshmallow devices for me raise error sql don’t wanna break anything that’s already working.

I do hope someone would stop by and explain why this happens and what the error really means.

Hope this saves anyone days of headache 🙂

EDIT:
For anyone Googling around, I also changed the original toas pointed out by Eugen Pechanec. See his comment and answer for details.
You would also want to change from checking against to with that.

,

You’re using incorrectly.

The audio session ID is a system wide unique identifier for the audio stream played by this MediaPlayer instance.

[…]

When created, a MediaPlayer instance automatically generates its own audio session ID. However, it is possible to force this player to be part of an already existing audio session by calling this method, android mediaplayer error -38 0. This method must be called before one of the overloaded methods.

You would obtain an audio session ID by calling .


What you’re probably looking for if you want to set the stream type is .

Newer API for this available since Android 5 is .

,

Make sure you don’t have too many objects active at once.

Implement the android mediaplayer error -38 0 and register it with your instance.
called when the end of a media source is reached during playback.

Release the instance once you are done playing all the files.


May be your listener only listen one time, then when it try to play the next one without prepared then it can crash. try this too

add this — > in your method before your

,

I had the same problem. Uploading many diferent audios to a Mediaplayer.

after 15 times it stopped to work.

I just add release every time before upload a new audio in the same Mediaplayer and this worked for me!

no more Error (1, -19)

hope helps!

,

I was getting the same problem, I solved it by adding the following code to release the player:

1- get Audio use Assets File

2- get Audio use res/raw folder.

]

Categories Codes
onErrorListener.onError(mediaPlayer, what, extra); }
Mockito.verify(errorListener).onError(mediaPlayer, 32, 22); assertThat(scheduler.size()).isEqualTo(0); assertThat(shadowMediaPlayer.getCurrentPositionRaw()).isEqualTo(675);
publicvoid invokeErrorListener(int what, int extra) { doStop(); state = ERROR; boolean handled = errorListener != null && errorListener.onError(player, what, extra); if (!handled) { invokeCompletionListener(); state = ERROR; } }
@Override publicvoid test(MethodSpec method) { final State state = error 21 grub finalboolean wasPaused = scheduler.isPaused(); scheduler.pause(); try { method.invoke(); } catch (InvocationTargetException e) { thrownew RuntimeException("Expected <" + method + "> to call onError rather than throw <" + e.getTargetException() + "> when called from <" + state + ">", e); } Mockito.verifyZeroInteractions(errorListener); final State finalState = shadowMediaPlayer.getState(); assertThat(finalState).isSameAs(ERROR); scheduler.unPause(); Mockito.verify(errorListener).onError(mediaPlayer, what, extra); Mockito.reset(errorListener); if (wasPaused) { scheduler.pause(); } } }
@Test publicvoid testScheduleErrorAtOffsetWhileNotPlaying() { info.scheduleErrorAtOffset(500, 1, 3); shadowMediaPlayer.setState(INITIALIZED); shadowMediaPlayer.setState(PREPARED); mediaPlayer.start(); scheduler.advanceBy(499); Mockito.verifyZeroInteractions(errorListener); scheduler.advanceBy(1); Mockito.verify(errorListener).onError(mediaPlayer, 1, 3); assertThat(shadowMediaPlayer.getState()).isSameAs(ERROR); assertThat(scheduler.advanceToLastPostedRunnable()).isFalse(); assertThat(shadowMediaPlayer.getCurrentPositionRaw()).isEqualTo(500); }
Question:I have a weird error message and can’t find solution. Project: Android with Eclipse IDE and Android SDK, min. API level 10, source code is attached. Problem: I can play none of my downloaded and saved media files from the application’s own data folder (/data/data/com.mypackage/myfile.mp4) by the MediaPlayer class. I double checked the video format. It can be even played when I place it into the /mnt/sdcard/… folder. Android shows a message saying “Cannot Play Video: Sorry, this video cannot be played”. In the log file I can find an error: MediaPlayer error(1, -2147483648)and Prepare failed. status=0x1. What’s the issue? Answer:The typical errors are as follows: 1. File path is in error. Incorrect directory or Url or Uri found. 2. Media file is in error, incompatible android mediaplayer error -38 0. 3. Missing permissions. In Android MediaPlayer mp = new MediaPlayer();does not create your apps’s own object. It uses “another” application and requires world-readablepermissions for the application’s local media files. “World-readable” means another application can see it. You can view the permissions of these files on the DDMS window in Eclipse IDE:
Set file permissions to Context.MODE_WORLD_READABLE or Context.MODE_WORLD_WRITEABLE
When your app is in error, you will probably see that “-rw——” gray line, which means that only your application has read/write permissions on your file(s). For applications targetting SDK versions greater than Android 2.3, these permission flags can be explicitly set if desired. See File -> setReadable(,), or FileOutputStream documentation for hints: Call openFileOutput() with the name of the file and the operating mode. This returns a FileOutputStream:

0 Comments

Leave a Comment