2 onlyarce onlyarce 于 2016.01.27 11:43 提问

小米手机播放视频报错stop called in state 1,error (-38, 0)

今天写demo,用小米手机播放手机里本地的视频,界面正常,但是视频不出现,在log里报错如下:
01-27 10:53:46.530: E/MediaPlayer-JNI(21091): QCMediaPlayer mediaplayer NOT present
01-27 10:53:46.700: E/MediaPlayer-JNI(21091): QCMediaPlayer mediaplayer NOT present
01-27 10:53:46.820: E/MediaPlayer(21091): stop called in state 1
01-27 10:53:46.820: E/MediaPlayer(21091): error (-38, 0)
01-27 10:53:46.830: E/MediaPlayer(21091): start called in state 0
01-27 10:53:46.840: E/MediaPlayer(21091): Attempt to perform seekTo in wrong state: mPlayer=0x0, mCurrentState=0
01-27 10:53:46.880: E/MediaPlayer(21091): Error (-38,0)
01-27 10:53:46.920: E/MediaPlayer(21091): Should have subtitle controller already set

代码如下:
try {
player = new MediaPlayer();
// 重置为初始状态
player.reset();
// 设置音乐流的类型
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
// 设置video影片以surfaceviewholder播放
player.setDisplay(holder);
// 设置路径
player.setDataSource(Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/VideoCache/1453791771643.mp4");
player.prepareAsync();

        if (player != null) {
            player.stop();
        }
        player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {

                player.start();

            }
        });
    } catch (Exception e) {
        Log.e("HHHHHHHHHHHHHHHHHH", e.toString());
        e.printStackTrace();
    }

手机里还有个视频文件能播放,这个就不行,郁闷。

2个回答

91program
91program   Ds   Rxr 2016.01.27 11:46
onlyarce
onlyarce 我看过你这个帖子,也试过用MediaPlay的Creat方法创建,还是报一样的错误。
2 年多之前 回复
zhanghaoyangchao
zhanghaoyangchao   2016.01.28 12:11
       String wav_path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/VideoCache/1453791771643.mp4";

        File file = new File(wav_path);

        FileInputStream fis = new FileInputStream(file);
        mMediaPlayer.setDataSource(fis.getFD());

                    试试这样可不可以
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Android MediaPlayer Error (-38, 0) “stop called in state 0”
I have looked at various different websites looking for a solution for this problem in my code. It is a basic audio player with 3 buttons: play, pause and stop. Play and pause work ok and so does stop
Error: MediaPlayer start called in state 1 & 64
MediaPlayer start called in state 1 :调用start时出现这个错误,表示mediaplayer没有获取到资源。 这里有几种情况:1、路径问题,可以设置断点查看参数。2、权限问题,用DDMS查看资源所在文件夹属性即可验证。 解决:对于权限问题,只要在AndroidManifest文件中,添加用户权限即可 MediaPlayer st
android错误之MediaPlayer用法的Media Player called in state *
用到Media Player,遇到几个问题,记一下用法就不说了,使用的时候最好参考一下mediaPlayer的这张图第一个错误是Media Player called in state 8这个是因为在调用start之前没有prepare,因为我是用了mediaPlayer = MediaPlayer.create(context, R.raw.notice);去初始化的播放器,这个接口说明只要成功
【Android】- MediaPlayer错误之MediaPlayer start called in state 0
MediaPlayer start called in state 0 主要原因在于start()出现问题,在start()播放开始之前没有调用prepare(),在初始化MediaPlayer时,通过create()方法设置数据源,则不能写mediaPlayer.prepare()方法,只要成功返回播放器就不需要prepare,但是: 如果反复多次调用了start()和stop()方法,就会出现MediaPlayer start called in state 0 错误,因此需要在start()之前必须重
Mediaplayer start called in state 0
在使用Mediaplayer播放音频时,出现start called in state 0,原因主要是因为你在音频的播放顺序出现了问题
音乐播放器之--错误状态下调用导致的异常
MediaPlayer必须在合适的状态下调用合适的方法,否则会出现异常,下面列出常见错误信息和说明: 1、E/MediaPlayer(11310): stop called in state 1 调用 stop()之前,MediaPlayer的状态不在【Started, Paused, Prepared or PlaybackCompleted state】范围内。只有在这个范围内的状
【完美解决系列】Android MediaPlayer stop called in state 1
经过测试发现,是因为调用stop函数时,导致的问题。 原代码为:MediaPlayer player = MediaPlayer.create(context, R.raw.music_1);private void stop() { if (player != null) { player.stop(); player.reset(
android播放器MediaPlayer快进报错error (-2147483648, 0)&error (-38, 0),分析log解决问题
================================================= 01-02 09:43:00.842: E/tips(6475): ************setViewSeekTo: opCode:1003;curPos:8935;desPos:10635 01-02 09:43:00.842: E/tips(6475): seekTo:106
WebView called on thread 'JavaBridge'的问题和MediaPlayer stop called in state 1报错解决记录
MdeiaPlayer 的问题 ==E/MediaPlayer(5404): stop called in state 1==出现这个问题是由于mediaplayer还没有start就调用了stop ==W/MediaPlayer-JNI(6246): MediaPlayer finalized without being released==mediaplayer只要创建再不用的时候进行rele
setOutputFormat called in an invalid state: 1
在编写一个简单的录像应用程序的时候,爆出如下异常: E MediaRecorder: setOutputFormat called in an invalid state: 1 E AndroidRuntime: java.lang.IllegalStateException E AndroidRuntime: at android.media.MediaRecorder.setOutput