问题描述
- 小米手机播放视频报错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(); }
手机里还有个视频文件能播放,这个就不行,郁闷。
解决方案
[多媒体] QCMediaPlayer mediaplayer NOT present
解决方案二:
String wav_path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/VideoCache/1453791771643.mp4";
File file = new File(wav_path);
FileInputStream fis = new FileInputStream(file);
mMediaPlayer.setDataSource(fis.getFD());
试试这样可不可以
时间: 2024-12-12 05:56:23