简体   繁体   English

java.io.IOException:准备失败。:Android中的status = 0x1

[英]java.io.IOException: Prepare failed.: status=0x1 in Android

I tried to play a file in ListView with mediaPlayer class. 我尝试使用mediaPlayer类在ListView播放文件。

Like this: 像这样:

public void initializeViews() {
    Intent intent = getIntent();
    String fName = intent.getStringExtra("fileName");
    fileName = (TextView) findViewById(R.id.fileName);
    duration = (TextView) findViewById(R.id.songDuration);
    seekbar = (SeekBar) findViewById(R.id.seekBar);
    playBtn = (ImageButton) findViewById(R.id.media_play);
    try {
        mediaPlayer = new android.media.MediaPlayer();
        mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mediaPlayer.setDataSource(fName);
        mediaPlayer.prepare();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    fileName.setText(fName.substring(fName.lastIndexOf("/") + 1));
    finalTime = mediaPlayer.getDuration();
    seekbar.setOnSeekBarChangeListener(mOnSeek);
    seekbar.setMax((int) finalTime);
    seekbar.setClickable(true);
    mediaPlayer.start();
    timeElapsed = mediaPlayer.getCurrentPosition();
    seekbar.setProgress((int) timeElapsed);
    durationHandler.postDelayed(updateSeekBarTime, 200);
}

I search on the internet, and the most question is check the path to file, but the fName got the full path to a file. 我在互联网上搜索,最主要的问题是检查文件的路径,但是fName获得了文件的完整路径。 But I don't know it shows exception: 但我不知道它显示异常:

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

All log when application occurs exception: 应用程序发生异常时的所有日志:

E/MediaPlayer: error (1, -2147483648)
W/System.err: java.io.IOException: Prepare failed.: status=0x1
W/System.err:     at android.media.MediaPlayer.prepare(Native Method)
W/System.err:     at kr.co.composer.callrecord.media.AudioPlayer.initializeViews(AudioPlayer.java:56)
W/System.err:     at kr.co.composer.callrecord.media.AudioPlayer.onCreate(AudioPlayer.java:42)
W/System.err:     at android.app.Activity.performCreate(Activity.java:5231)
W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
W/System.err:     at android.app.ActivityThread.access$800(ActivityThread.java:135)
W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err:     at android.os.Looper.loop(Looper.java:136)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5001)
W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err:     at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
W/System.err:     at dalvik.system.NativeStart.main(Native Method)
E/MediaPlayer: Attempt to call getDuration without a valid mediaplayer
E/MediaPlayer: error (-38, 0)
E/MediaPlayer: start called in state 0
E/MediaPlayer: error (-38, 0)
E/MediaPlayer: Error (-38,0)
E/MediaPlayer: Error (-38,0)
W/EGL_genymotion: eglSurfaceAttrib not implemented
stop called in state 0
error (-38, 0)
stop called in state 0
error (-38, 0)
Error (-38,0)
Error (-38,0)
stop called in state 0
error (-38, 0)
Error (-38,0)
pause called in state 0
error (-38, 0)

Possible caused by reading permission. 可能是由于阅读许可所致。 Fix by inserting the permission in manifest file: 通过在manifest文件中插入权限来解决:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.io.IOException:准备失败。:状态= 0x1 - java.io.IOException: Prepare failed.: status=0x1 Android MediaPlayer java.io.IOException: Prepare failed.: status=0x1, 无法修复 - Android MediaPlayer java.io.IOException: Prepare failed.: status=0x1, cant fix java.io.IOException:准备失败:状态= 0x1 - java.io.IOException:prepared failed:status=0x1 无法使用java.io.IOException创建媒体播放器:setDataSourceFD失败:状态= 0x80000000在2.3.3安卓平板电脑 - Unable to to create media player with java.io.IOException: setDataSourceFD failed.: status=0x80000000 in 2.3.3 android tablet 使用SurfaceView仅在三星GT-I8260中渲染视频时出现问题。 IOException:准备失败。:status = 0x1 - Problems rendering video only in Samnsung GT-I8260 using SurfaceView. IOException: Prepare failed.: status=0x1 Android MediaPlayer return Prepare failed.: status=0x1 on device but running in emulator - Android MediaPlayer return Prepare failed.: status=0x1 on device but runs in emulator java.io.IOException:setdatasource失败状态= 0xFFF - java.io.IOException:setdatasource failed status = 0xFFF java.io.IOException:HTTP请求失败,HTTP状态:500使用WCF for android在android中 - java.io.IOException: HTTP request failed, HTTP status: 500 in android using WCF for android java.io.IOException:所有收集器的初始化失败。 最后一个收集器中的错误是:null - java.io.IOException: Initialization of all the collectors failed. Error in last collector was :null 索引器:java.io.IOException:作业失败 - Indexer: java.io.IOException: Job failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM