googlesamples / androidtv-sample-inputs

Sample Channel App (TV Input Service) on Android TV using TIF
https://developer.android.com/training/tv/tif
Apache License 2.0
492 stars 241 forks source link

Use current ExoPlayer for Rich sample #7

Closed micolous closed 8 years ago

micolous commented 8 years ago

At present, this is using a bundled version of ExoPlayer 1.2.4. ExoPlayer 1.5.5 is out, and supports more codecs. These codecs are required for some IPTV services.

ExoPlayer is pretty much required for any sort of remote streaming setup, as MediaPlayer is extremely sensitive to latency and has small and unconfigurable buffers. Ideally, the Simple sample should also use ExoPlayer.

This other project by @Fleker appears to have an implementation of TvInputPlayer which works with ExoPlayer 1.5.3, but not 1.5.5:

https://github.com/Fleker/CumulusTV/blob/master/app/src/main/java/com/example/android/sampletvinput/player/TvInputPlayer.java

However, it does not support subtitles.

Note: I am not affiliated with the author of the other project, just been banging my head trying to get progressive HTTP streaming via udpxy working reliably for the last few hours... :disappointed:

Fleker commented 8 years ago

I don't think there's a major difference between 1.5.3 and 1.5.5, but it will be using the latest version next time I update my project.

As for subtitle integration, is that something you know about? It would be great if you could contribute to the project as I don't really know where to start.

micolous commented 8 years ago

I had a go at porting this based on your CumulusTV code, but got stuck because of other ExoPlayer bugs. I was fiddling trying to get it to behave, only to find that there was an issue with the H264 stream my IPTV provider puts out and it also doesn't support MP2 audio. :disappointed:

As a result I probably got some working code, but then summarily destroyed it in the debugging process because I failed to use version control. Not a lot of changes occurred in 1.5.3 to 1.5.5 of ExoPlayer, but there's enough that it doesn't build cleanly out of the box.

I'm not sure of a solution to subtitle integration, as the streams I was attempting to work with either didn't have subtitles, or used Teletext / VBI subtitles (which I don't think are supported by ExoPlayer). I merely noted it as an omission, though I don't recall if the original Google sample code also omitted it.

In the end I used one of Kodi's IPTV plugins to write support for my IPTV provider. This took less than an hour to write a small Python script that translated the playlist file into the correct format, and rewrite the URLs to use udpxy. This is compared to the 12+ hours I spent attempting to use Android TV APIs.

CumulusTV could have saved me some trouble here, but I would have still run up against other codec issues anyway.

ryanseys commented 8 years ago

I'm working on adding this. And it will support subtitles! :smile:

ryanseys commented 8 years ago

I've updated the sample to use the latest ExoPlayer (1.5.6) and it supports subtitles (see the BipBop channel within this sample). You may have to clear the current data in your Live Channels app and reinstall the channels from this sample app to get it all to work properly.

Let me know if you encounter any issues.

micolous commented 8 years ago

Awesome, thanks!

It looks like half of my codec issue in ExoPlayer has also been fixed, so I'll have to have another attempt at making this work in future.