Exoplayer: Automatically identify any stream type

Created on 12 Aug 2017  路  7Comments  路  Source: google/ExoPlayer

I'm making a radio app for Android, and I'm looking into ExoPlayer as an alternative to the standard MediaPlayer because it has some limitations (eg. can't play AAC streams). Basically I have a list of radio URLs, and when the user selects a radio I feed the corresponding URL to ExoPlayer.

Unfortunately it doesn't seem to work on all streams... Some are .pls for which I guess I have to extract the mp3 URLs myself. Some AAC streams don't work (but they work on VLC or Firefox), and no HLS streams work. From the documentation, it looks like I need some special code for HLS and other formats. This is pretty tedious compared to simpler way of just feeding a URL to the player. Can ExoPlayer automatically detect the right format and use the corresponding extractor? Why do I have to detect the type of some special cases, when most format are already detected automatically?

enhancement

Most helpful comment

Ideally yes, it should be part of ExoPlayer. My suggestion was aimed towards working around this problem. We will update this issue once we get to it.

All 7 comments

No HLS stream work

This is possibly because an ExtractorMediaSource is being used instead of an HlsMediaSource.

If you don't have control over the media to be played, it will be necessary to sniff at MediaSource level. Otherwise the file extension could be checked (like in the demo app).

A preliminary solution could be having a pre-preparation sniff step that will read the first few byes to define the content type (e.g: HLS playlists start with #EXTM3U, DASH manifests should contain an MPD opening tag more or less a the start, etc. falling back on ExtractorMediaSource if all else fails). A proper solution, however, shouldn't use to different connections for this process.

A preliminary solution could be having a pre-preparation sniff step that will read the first few byes to define the content type

Could this function be embedded into ExoPlayer? Something like GuessMediaSource that will try to select the most appropriate function to call?

Ideally yes, it should be part of ExoPlayer. My suggestion was aimed towards working around this problem. We will update this issue once we get to it.

Is there alternatively another player for Android that can play any Internet audio stream? Perhaps VLC?

I am sure there are, but this probably falls outside the scope of this issue tracker.

@AquilesCanta @tonihei Are there any plans to include this feature?
It would be great if we no longer have to guess the correct MediaSource type based on the url.

We dropped the plan to add this feature for now under the assumption that the stream type is typically known in the app.
But we have a pending implementation that solves the issue (and prevents any duplicate data loads): https://github.com/tonihei/ExoPlayer/commit/4a8c860e8c9337c540862df844497c21ec613b57 There was some discussion around the details of this implementation and whether it's the right API approach, but you should be able to use it if you want.

Was this page helpful?
0 / 5 - 0 ratings