3

I'm trying to get a video player where I can select the quality of the video. Like Youtube: It selects 'auto' by default but with a switch you can select: 360p, 720p etc.

The 'auto' parts works now using this code: ```

        TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
        trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
        player = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, new DefaultLoadControl());

Later on I create a new DashMediaSource.

 return new DashMediaSource(uri, buildDataSourceFactory(true),
          new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);

So the video is playing now but how do I force a the quality now? So for example when I select 360p I want the player to select that representation.

<AdaptationSet segmentAlignment="true" subsegmentAlignment="true" subsegmentStartsWithSAP="1"> <Representation bandwidth="954483" codecs="avc1.4d401f" frameRate="525007/17491" height="360" id="VIDEO-1" mimeType="video/mp4" startWithSAP="1" width="640"> <BaseURL>video360.fmp4</BaseURL> <SegmentBase indexRange="914-1425" indexRangeExact="true"> <Initialization range="0-913"/> </SegmentBase> </Representation> <Representation bandwidth="2351904" codecs="avc1.4d401f" frameRate="525007/17491" height="720" id="VIDEO-2" mimeType="video/mp4" startWithSAP="1" width="1280"> <BaseURL>video720.fmp4</BaseURL> <SegmentBase indexRange="914-1425" indexRangeExact="true"> <Initialization range="0-913"/> </SegmentBase> </Representation> </AdaptationSet>

I've found the FixedTrackSelection and AdaptationSet but I don't come to a solution

Does someone know how I can achieve this?

raiders
  • 31
  • 3
  • The Exoplayer demo actually includes this functionality and there is an overview blog available: https://stackoverflow.com/a/44068596/334402 – Mick Jul 16 '18 at 15:22

0 Answers0