Exoplayer 2.9.4 平滑流

Exoplayer 2.9.4 SmoothStreaming

我正在使用 explayer 2.9.4,我不知道如何使用 Exoplayer 创建流畅的流式传输。我在互联网上搜索了几天,但没有找到。 我的代码是这样的,但这是我需要使用 DASH

的正常流式传输
    TrackSelector trackSelector = new DefaultTrackSelector();
    exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
    Uri videoURI = Uri.parse(videoURL);
    DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory( Util.getUserAgent(this, "My Streamer"));
    mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory) .createMediaSource(videoURI);

并且正在尝试使用 Whosebug 中的一些代码,如下所示:

     DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory( Util.getUserAgent(this, "FTV Stream Albania"));
        dashMediaSource = new DashMediaSource(videoURI, dataSourceFactory, new DefaultDashChunkSource.Factory(dataSourceFactory), null, null);
        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter));

但我收到错误:

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........

文档很差。任何帮助将不胜感激。

解决方案是我从 ExoPlayer Github Soruce codes:

添加了两个文件

DownloadTracker.javaDemoDownloadService.java 然后从 PlayerActivity.java 得到了我需要的代码,现在效果很好。

对于使用 ExoPlayer V2.9.4 进行 DASH 流式传输:

DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
                Util.getUserAgent(this, getPackageName())); //1. Create the data source object
MediaSource dashMediaSource = new DashMediaSource.Factory(dataSourceFactory)
                        .createMediaSource(mUri); //2. Create mediaSource object of DASH media type 

TrackSelection.Factory trackSelectionFactory =
                    new AdaptiveTrackSelection.Factory(); //3. Create AdaptiveTrackSelection factory object 
TrackSelector trackSelector =
                    new DefaultTrackSelector(trackSelectionFactory); //4. Create DefaultTrackSelector object
exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector); //5. Create exoPlayer object
exoPlayer.prepare(mediaSource); //6. prepare the creates exoPlayer object with mediaSource (dash mediaSource in your case)