Android 媒体播放器错误 (100,0)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11985815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:23:01  来源:igfitidea点击:

Android Media Player Error (100,0)

androidandroid-mediaplayerandroid-video-player

提问by Pranav

I have read all the error codes given on the web.

我已经阅读了网络上给出的所有错误代码。

Error specifies:

错误指定:

const PVMFStatus PVMFInfoLast = 100; " Placeholder for end of range"

const PVMFStatus PVMFInfoLast = 100; “范围结束的占位符”

But I didn't able to handle this error, thanks for helping.

但我无法处理这个错误,感谢您的帮助。

回答by Pranav

Implement OnErrorListener to your class.

为您的类实现 OnErrorListener。

inside the class body write

在类体内写

video_view.setOnErrorListener(this);

then overwrite the method OnError(MediaPlayer mp , int what , int extra) with this method

然后用这个方法覆盖方法 OnError(MediaPlayer mp , int what , int extra)

@Override
public boolean onError(MediaPlayer mp, int what, int extra) 
{
    if (what == 100)
    {
        video_view.stopPlayback();
        Intent inn = new Intent(HelloInterruptVideoStream.this,TabAct.class);
        startActivity(inn);
    }
    else if (what == 1)
    {
        pb2.setVisibility(View.GONE);
        Log.i("My Error ", "handled here");
        video_view.stopPlayback();
        Intent inn = new Intent(HelloInterruptVideoStream.this,TabAct.class);
        startActivity(inn);
    }
    else if(what == 800)
    {
        video_view.stopPlayback();
        Intent inn = new Intent(HelloInterruptVideoStream.this,TabAct.class);
        startActivity(inn);
    }
    else if (what == 701)
    {
        video_view.stopPlayback();
        Intent inn = new Intent(HelloInterruptVideoStream.this,TabAct.class);
        startActivity(inn);
    }
    else if(what == 700)
    {
        video_view.stopPlayback();

        Toast.makeText(getApplicationContext(), "Bad Media format ", Toast.LENGTH_SHORT).show();
        Intent inn = new Intent(HelloInterruptVideoStream.this,TabAct.class);
        startActivity(inn);
    }

    else if (what == -38)
    {
        video_view.stopPlayback();
        Intent inn = new Intent(HelloInterruptVideoStream.this,TabAct.class);
        startActivity(inn);
    }
    return false;
}

回答by p37td8

I faced with this problem on Android 1.5.

我在 Android 1.5 上遇到了这个问题。

mMP = new MediaPlayer();
mMP.setOnCompletionListener(new CompletionListener());
mMP.setOnErrorListener(new ErrorListener());    
final FileInputStream fileInStream = new FileInputStream(mFileName);    
mMP.setDataSource(fileInStream.getFD());        
mMP.prepare();
mMP.play();
01-14 01:57:26.248: W/MediaPlayer(1971): MediaPlayer server died!
01-14 01:57:26.258: E/MediaPlayer(1971): error (100, 0)
01-14 01:57:26.258: E/MediaPlayer(1971): Error (100,0)

It happens when mp3 files duration is less than 1 second. This is an android.media.MediaPlayerbug.

当 mp3 文件持续时间小于 1 秒时会发生这种情况。这是一个android.media.MediaPlayer错误。

The solution is to make mp3 files duration more than 1 second.

解决办法是让mp3文件的时长超过1秒。