1
我使用下面的代碼使用EXOPlayer播放視頻,但不播放。在EXOPlayer中播放視頻
視頻格式爲mp4
格式。我在哪裏出錯了? 它顯示錯誤 -
com.google.android.exoplayer.ExoPlaybackException: java.io.IOException: Failed to instantiate extractor.
代碼 -
loadvideo("res:/" + R.raw.samplevider);
private void loadvideo(String path) {
player = ExoPlayer.Factory.newInstance(2, 1000, 5000);
Uri uri = Uri.parse(path);
sampleSource = new FrameworkSampleSource(getActivity().getApplicationContext(), uri, null);
// 1. Instantiate the player.
// 2. Construct renderers.
videoRenderer = new MediaCodecVideoTrackRenderer(getActivity().getApplicationContext(),sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,MediaCodecSelector.DEFAULT);
// 3. Inject the renderers through prepare.
player.prepare(videoRenderer, audioRenderer);
// 4. Pass the surface to the video renderer.
player.sendMessage(videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surfaceView.getHolder().getSurface());
// 5. Start playback.
player.setPlayWhenReady(true);
}
它也不工作。該問題與文件編碼有關。 –
@LostPuppy你有解決方案嗎?請幫助我getDuration()爲ExoPlayer並看看http://stackoverflow.com/questions/39777975/not-able-to-get-getduration-for-aac-file-using-exoplayer –