gpt4 book ai didi

android - Exoplayer 不播放任何视频

转载 作者:行者123 更新时间:2023-11-29 14:35:47 25 4
gpt4 key购买 nike

让 Exoplayer 工作时遇到问题。我设法从 url 加载了视频。但它只播放音频。所以我做错了什么。

    BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
SimpleExoPlayer exoPlayer = ExoPlayerFactory.newSimpleInstance(simpleExoPlayerView.getContext(), trackSelector, loadControl);

Uri mp4VideoUri = Uri.parse(videoUri);
DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory("ExoPlayerDemo");
ExtractorsFactory extractor = new DefaultExtractorsFactory();

MediaSource videoSource = new ExtractorMediaSource(mp4VideoUri, dataSourceFactory, extractor, null, null);
exoPlayer.prepare(videoSource);

exoPlayer.setPlayWhenReady(true);

这就是我只能播放音频的方式。不确定我应该更改什么。

最佳答案

看起来你错过了将玩家绑定(bind)到玩家 View

Attaching player to view

The ExoPlayer library provides a SimpleExoPlayerView, which encapsulates a PlaybackControlView and a Surface onto which video is rendered. A SimpleExoPlayerView can be included in your application’s layout xml. Binding the player to the view is as simple as:

// Bind the player to the view.
simpleExoPlayerView.setPlayer(player);

If you require fine-grained control over the player controls and the Surface onto which video is rendered, you can set the player’s target SurfaceView, TextureView, SurfaceHolder or Surface directly using SimpleExoPlayer’s setVideoSurfaceView, setVideoTextureView, setVideoSurfaceHolder and setVideoSurface methods respectively. You can use PlaybackControlView as a standalone component, or implement your own playback controls that interact directly with the player. setTextOutput and setId3Output can be used to receive caption and ID3 metadata output during playback.

关于android - Exoplayer 不播放任何视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41623075/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com