Android MediaPlayer java.io.IOException: Prepare failed.: status=0x1

Lonely Twinky

I am using Android's MediaPlayer to set up a URL stream in my application. I have tried several different posts to deal with the exit code and error: (1, -2147483648).

I have attempted several different streams, but I can't seem to get the MediaPlayer to work. I have thought about moving over the Google's ExoPlayer but it is a little more complex and I don't want to jump ship in case I am missing something.

MediaPlayer:

private MediaPlayer player;
String url = "http://199.180.75.118:80/stream";     //temp stream
private void initializeMediaPlayer() {
    player = new MediaPlayer();
    player.setAudioAttributes( new AudioAttributes.Builder()
        .setUsage(AudioAttributes.USAGE_MEDIA)
        .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
        .build());

    try { 
        player.setDataSource(url);
        player.prepareAsync();
        player.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared(MediaPlayer mp) {
                mp.start();
            }
        });
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } 
}

I have also included the android permission:

<uses-permission android:name="android.permission.INTERNET" /> 

I have attempted to use the original stream type (but it throws a deprecated warning):

player.setAudioStreamType(AudioManager.STREAM_MUSIC);

So instead I used the .setAudioAttributes(...) I have attempted to just run prepare() instead of prepareAsync() which gave the title of the problem, but I still result in the same error. I have looked into the actual error definition with no luck either (Android MediaPlayer error (1, -2147483648)). I don't think it is a source issue since I have tried multiple other streams. Please let me know if I am skipping over something crucial that might be causing my error.

Edit If it helps at all, I have been looking into my calls and I found out that MediaPlayer is never calling onPrepared(...). I checked the Content-Types of all of the media I have been testing and they have all been audio/MPEG headers. So I don't understand why the MediaPlay isn't accessing the onPrepared.

fancyjyl
private void initializeMediaPlayer() {
        player = new MediaPlayer();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            player.setAudioAttributes(new AudioAttributes.Builder()
                    .setUsage(AudioAttributes.USAGE_MEDIA)
                    .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
                    .setLegacyStreamType(AudioManager.STREAM_MUSIC)
                    .build());
        } else {
            player.setAudioStreamType(AudioManager.STREAM_MUSIC);
        }
        try {
            player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer mp) {
                    mp.start();
                }
            });
            player.setDataSource(url);
            player.prepareAsync();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

onPrepared calling in seconds.

In android 9, check this https://developer.android.com/training/articles/security-config

AndroidManifest.xml add networkSecurityConfig attributes

...
<application
android:networkSecurityConfig="@xml/network_security_config"
...>
...

in src/res/xml add network_security_config.xml file

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
            <certificates src="user" />
        </trust-anchors>
    </base-config>
</network-security-config>

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Android MediaPlayer java.io.IOException : 준비 실패. : 상태 = 0x1

분류에서Dev

Jenkins Slave Prints message Cannot contact slave-host : java.io.IOException : Remote call on Channel to /10.0.2.2 failed

분류에서Dev

java.io.IOException : Android Firebase의 FIS_AUTH_ERROR

분류에서Dev

Android Bluetooth : java.io.IOException : 서비스 검색 실패

분류에서Dev

Android Studio logcat BUG 스팸 java.io.IOException : 연결이 거부 됨

분류에서Dev

Unhandled Exception java.io.iOException

분류에서Dev

java.io.IOException : 유효하지 않은 헤더 서명; 0x6D78204C4D54483C 읽기, 0xE11AB1A1E011CFD0 예상

분류에서Dev

Android : java.io.IOException : 호스트 이름이 확인되지 않았습니다.

분류에서Dev

What does exit status 1 (0x1) mean for a Windows GUI program?

분류에서Dev

org.openqa.selenium.WebDriverException : 때 java.io.IOException

분류에서Dev

때 java.io.IOException : grpc 실패

분류에서Dev

Alfresco 모바일 : Kerberos 및 iOS 로그인 : java.io.IOException : ASN.1 유형 0x3a 디코딩이 지원되지 않음

분류에서Dev

Android Mediaplayer Null 포인트 예외 (Java)

분류에서Dev

MediaPlayer-java.io.FileNotFoundException : 컨텐츠 제공자 없음

분류에서Dev

Java Closing an IOStream in finally giving error: Unhandled Exception: java.io.IOException

분류에서Dev

java.io.IOException : 잘못된 키 클래스 : X가 <ReducerOutputClass> 클래스가 아닙니다.

분류에서Dev

Android FFmpegMediaPlayer-MediaPlayer 오류 (0, 0)

분류에서Dev

Android 개발, Gottox socket.io-java-client : file not fount Exception /socket.io/1/

분류에서Dev

Android MediaPlayer setsurface illegalstateexception

분류에서Dev

Android MediaPlayer :: 문제

분류에서Dev

Android MediaPlayer 오류

분류에서Dev

java.io.IOException : 지원되지 않는 객체 유형

분류에서Dev

ERROR: java.io.IOException: Table Namespace Manager not ready yet, try again later

분류에서Dev

java.io.IOException에서 HTTP 상태 코드 추출

분류에서Dev

ANDROID : MediaPlayer에 오류 표시 (1, -19)

분류에서Dev

오류 : android.content.res.Resources $ NotFoundException : 문자열 리소스 ID # 0x1

분류에서Dev

Android 캔버스 저장 항상 java.io.IOException : 열기 실패 : ENOENT (해당 파일 또는 디렉토리 없음)

분류에서Dev

java.security.cert.CertificateParsingException : java.io.IOException : 알 수없는 명명 된 곡선 : 1.3.132.0.38

분류에서Dev

java.io.IOException : 지정된 포트 범위에서 Blob 서버에 대한 소켓을 할당 할 수 없음 : 0

Related 관련 기사

  1. 1

    Android MediaPlayer java.io.IOException : 준비 실패. : 상태 = 0x1

  2. 2

    Jenkins Slave Prints message Cannot contact slave-host : java.io.IOException : Remote call on Channel to /10.0.2.2 failed

  3. 3

    java.io.IOException : Android Firebase의 FIS_AUTH_ERROR

  4. 4

    Android Bluetooth : java.io.IOException : 서비스 검색 실패

  5. 5

    Android Studio logcat BUG 스팸 java.io.IOException : 연결이 거부 됨

  6. 6

    Unhandled Exception java.io.iOException

  7. 7

    java.io.IOException : 유효하지 않은 헤더 서명; 0x6D78204C4D54483C 읽기, 0xE11AB1A1E011CFD0 예상

  8. 8

    Android : java.io.IOException : 호스트 이름이 확인되지 않았습니다.

  9. 9

    What does exit status 1 (0x1) mean for a Windows GUI program?

  10. 10

    org.openqa.selenium.WebDriverException : 때 java.io.IOException

  11. 11

    때 java.io.IOException : grpc 실패

  12. 12

    Alfresco 모바일 : Kerberos 및 iOS 로그인 : java.io.IOException : ASN.1 유형 0x3a 디코딩이 지원되지 않음

  13. 13

    Android Mediaplayer Null 포인트 예외 (Java)

  14. 14

    MediaPlayer-java.io.FileNotFoundException : 컨텐츠 제공자 없음

  15. 15

    Java Closing an IOStream in finally giving error: Unhandled Exception: java.io.IOException

  16. 16

    java.io.IOException : 잘못된 키 클래스 : X가 <ReducerOutputClass> 클래스가 아닙니다.

  17. 17

    Android FFmpegMediaPlayer-MediaPlayer 오류 (0, 0)

  18. 18

    Android 개발, Gottox socket.io-java-client : file not fount Exception /socket.io/1/

  19. 19

    Android MediaPlayer setsurface illegalstateexception

  20. 20

    Android MediaPlayer :: 문제

  21. 21

    Android MediaPlayer 오류

  22. 22

    java.io.IOException : 지원되지 않는 객체 유형

  23. 23

    ERROR: java.io.IOException: Table Namespace Manager not ready yet, try again later

  24. 24

    java.io.IOException에서 HTTP 상태 코드 추출

  25. 25

    ANDROID : MediaPlayer에 오류 표시 (1, -19)

  26. 26

    오류 : android.content.res.Resources $ NotFoundException : 문자열 리소스 ID # 0x1

  27. 27

    Android 캔버스 저장 항상 java.io.IOException : 열기 실패 : ENOENT (해당 파일 또는 디렉토리 없음)

  28. 28

    java.security.cert.CertificateParsingException : java.io.IOException : 알 수없는 명명 된 곡선 : 1.3.132.0.38

  29. 29

    java.io.IOException : 지정된 포트 범위에서 Blob 서버에 대한 소켓을 할당 할 수 없음 : 0

뜨겁다태그

보관