Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose HLS master playlist as part of the object returned via ExoPlayer.getCurrentManifest #2537

Closed
rileymacdonald opened this issue Mar 7, 2017 · 5 comments
Assignees

Comments

@rileymacdonald
Copy link

I'm upgrading from ExoPlayer r1.5.9 to r2.2.0. How can I receive a reference to the HlsMasterPlaylist when loading HLS content? I'm assuming this is the only way to get a reference to the variants; Previously when using ExoPlayer r1.x, the onSingleManifest() callback returned an HlsPlaylist which could be cast to a HlsMasterPlaylist in order to get a reference the variants (which now appears to be List<HlsUrl> variants;):

new ManifestFetcher.ManifestCallback<HlsPlaylist>() {
    public void onSingleManifest(HlsPlaylist playlist) {
        (HlsMasterPlaylist) playlist // ...
    }
}

This callback appears to have been removed in r2.x.

Here is an example of the ExoPlayer instance I'm using:

ExoPlayer player = ExoPlayerFactory.newInstance(
    Renderer[
        new MediaCodecVideoRenderer(appContext, MediaCodecSelector.DEFAULT),
        new MediaCodecAudioRenderer(MediaCodecSelector.DEFAULT),
        new TextRenderer(...),
        new MetadataRenderer(...)
    ],
    new DefaultTrackSelector(new AdaptiveVideoTrackSelection.Factory(
        new DefaultBandwidthMeter()
    ) 
    new DefaultLoadControl(
        new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE)
    )
);

Here is an example of the MediaSource I'm using:

MediaSource mediaSource = new HlsMediaSource(
    uri,
    new DefaultDataSourceFactory(
        appContext, 
        userAgent, 
        new DefaultBandwidthMeter(), 
    handler, 
    adaptiveMediaSourceEventListener)

player.prepare(mediaSource);

Is there a listener which exposes the variants I require from HlsMasterPlaylist? Is there documentation explaining these types of changes from r1.x to r2.x which I can reference? I hope I've provided enough information to answer this question. Thanks.

@ojw28 ojw28 added the question label Mar 8, 2017
@ojw28
Copy link
Contributor

ojw28 commented Mar 8, 2017

We should probably expose this via ExoPlayer.EventListener.onTimelineChanged. Currently we're exposing the media playlist only. Although what information do you actually need to pull out of the HlsMasterPlaylist? It's fairly likely the information you need is exposed somewhere else, just not in HlsMasterPlaylist form.

@rileymacdonald
Copy link
Author

I'm looking to pull the variant/rendition count for reporting reasons. If this information is available somewhere else I won't need the HlsMasterPlaylist.

@ojw28
Copy link
Contributor

ojw28 commented Mar 8, 2017

You could try using EventListener.onTracksChanged. The trackGroups variable will hold information about the tracks we've determined are present in the media. It becomes a little complicated because the representation of tracks here splits out muxed streams, but if you're dealing with reasonably simple cases it should be possible to derive the numbers you're looking for from the groups.

Else you'll probably have to wait for us to expose the master playlist through onTimelineChanged. Marking this as an enhancement to track doing this.

@ojw28 ojw28 changed the title [Question] How to get a reference to variants when loading HLS content? Expose HLS master playlist as part of the object returned via ExoPlayer.getCurrentManifest Mar 8, 2017
@rileymacdonald
Copy link
Author

Thanks! I was able to loop over the TracksGroupArray from onTracksChanged() and fetch the desired video formats to determine the variant count and details about the renditions I required.

@AquilesCanta
Copy link
Contributor

For the record. We are changing the API in the next push:

onTimelineChanged and getCurrentManifest will now return an HlsManifest, which holds a reference to the master playlist and the current window snapshot.

ojw28 pushed a commit that referenced this issue Mar 16, 2017
This allows the user to get the HlsMasterPlaylist through
Exoplayer.getCurrentManifest().

Issue:#2537

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=150232455
@ojw28 ojw28 closed this as completed Mar 16, 2017
@google google locked and limited conversation to collaborators Jul 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants