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币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!