how do I enable and also select different subtitles that are embedded in a Vimeo video in HLS format using Exoplayer, ExoMedia or another player? In iOS this same video already presents the option of subtitles natively but in Android I cannot find means to implement it.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
My answer here will look a lot like this one, so you might want to check that one out first.
ExoPlayer is the library you'll want for Android. It's a non- trivial task to get the subtitles to show, but the demo app for that library has all the code you'll need to get them working on an HLS video. More specifically the
PlayerActivity
class. You can go to HLS -> "Apple 16x9 basic stream" in the demo app and that video has a ton of subtitles (aka "text tracks").Just to simplify their code so that it doesn't rely on the helper (and so you can see how it works just on closed captions) I've written/documented some of their code below.
Then if you post the following code into the end of their
initializePlayer()
method, you'll get an idea of how these pieces fit together.The code above is super sloppy, but it should hopefully at least get you started in the right direction. I wouldn't recommend using any piece of what's written - it should mostly be to get an idea of how the different pieces fit together. What they have in the demo app is a little better in that their code is very reusable for the different track selection types (since you can have video, audio, and text tracks).
This works well!
rendererIndex
is0
for Video,1
for Audio and2
for Subtitles/Text