3

I would like to play a MP4 video from a URL in my Android TV app.

I couldn't find an example in the Sample code (https://github.com/googlesamples/androidtv-Leanback).

Does anyone know how to do that? Do I need to create my own Activity or is there a standard one in the leanback support library?

Simon Reggiani
  • 550
  • 10
  • 18

1 Answers1

3

The androidtv-Leanback example already includes video playback.

If you take a look at the PlaybackOverlayActivity, you will see that the VideoView class is used to play sample videos (you can find the documentation here).

However, there is no standard component in the Leanback support library, so you will have to define an Activity yourself.

Sebastiano
  • 12,289
  • 6
  • 47
  • 80
  • Wow. That seems really complicated for just playing a video and some controls... Have you done any app with this kind of video playback? – Simon Reggiani Jan 11 '15 at 23:08
  • I don't think it's that complicated (in terms of code quantity and complexity). Usually, video playback involves quite a lot of work. For the controls part, the `PlaybackOverlayFragment` widget does a great part of the heavy lifting for you (see here: https://developer.android.com/reference/android/support/v17/leanback/app/PlaybackOverlayFragment.html) – Sebastiano Jan 12 '15 at 09:57
  • Yeah I was finally able to copy paste `PlaybackOverlayFragment` and `PlaybackOverlayActivity` and tweak it a little bit to make it work in my app. Thanks for the help. – Simon Reggiani Jan 12 '15 at 20:41