我正在从存储在 firebase 存储中的 URL 流式传输视频,并且我正在使用以下代码使用 ExoPlayer 流式传输视频
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter));
LoadControl loadControl = new CustomLoadControl();
exoPlayer = ExoPlayerFactory.newSimpleInstance(SafetyTVHomeActivity.this, trackSelector, loadControl);
Uri videoUri = Uri.parse(videourl);
DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory("exoplayer_video");
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource mediaSource = new ExtractorMediaSource(videoUri, dataSourceFactory, extractorsFactory, null, null);
exoPlayerView.setPlayer(exoPlayer);
exoPlayer.addListener(new PlayerEventListener());
exoPlayer.prepare(mediaSource, false, false);
exoPlayer.seekTo(0, 0);
一切都很好,视频被流式传输。但我面临的问题是启动视频的初始加载时间太长(5 秒以上)。我想将启动视频的初始加载时间减少到(0-2 秒)。有没有办法使用 exoplayer 来实现这一点?
我还尝试使用以下代码在 exoplayer 中使用 DASH 媒体源
Uri videoUri = Uri.parse(videourl);
DataSource.Factory dataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(SafetyTVHomeActivity.this, "app-name"));
MediaSource mediaSource = new DashMediaSource.Factory(dataSourceFactory).createMediaSource(videoUri);
exoPlayer = ExoPlayerFactory.newSimpleInstance(this);
exoPlayer.prepare(mediaSource);
exoPlayerView.setPlayer(exoPlayer);
exoPlayer.addListener(new PlayerEventListener());
我在破折号媒体源中使用了相同的 Firebase 存储 URL,但出现以下错误
ExoPlayerImplInternal: Source error.
com.google.android.exoplayer2.ParserException: org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT G@��B�%���������...@2:79 in java.io.InputStreamReader@c587547) at com.google.android.exoplayer2.source.dash.manifest.DashManifestParser.parse(DashManifestParser.java:105) at........
谁能帮我解决这个问题。
我的主要目标是从 URL 流式传输视频,启动视频的初始加载时间应该是 0-2 秒(TikTok 的方式)。任何帮助都会非常有帮助。