我在我的Android应用程序中使用exo播放器从服务器播放视频。 棒棒糖+的纵向模式下的视频播放,但横向模式下的kitkat版本视频播放。
以下是代码
Uri uri = Uri.parse(path);
Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
DataSource dataSource = new DefaultUriDataSource(this, null, getUserAgent(this, "ExoPlayerExample"));
ExtractorSampleSource sampleSource = new ExtractorSampleSource(
uri, dataSource, allocator, BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(
this, sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT);
MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(
sampleSource, MediaCodecSelector.DEFAULT);
player = ExoPlayer.Factory.newInstance(RENDERER_COUNT);
player.prepare(videoRenderer, audioRenderer);
player.sendMessage(videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surfaceView.getHolder().getSurface());
player.setPlayWhenReady(true);