-1

I saw some Android apps have videos embedded in some pages. By default, only the video's thumbnail is displayed. Once you click this thumbnail, it will invoke the default media player to play the video. So, how to implement such feature? Do I need to retrieve the thumbnail first and then create a listener for the thumbnail while the listener will invoke an intent to call the media play activity? Examples are preferred.

injoy
  • 3,993
  • 10
  • 40
  • 69

1 Answers1

0

Use the Youtube API

there is an official YouTube Android Player API wich you can use. This is a bit more complicated but it is working better than other solutions using webclients.

First you must register your app in Googles API Console. This is completely free until your app gets over 25k request a month (or something like that). There are complete and great tutorials under the link. I hope you can understand them. If not, ask! :)

OR

VideoView control with a FrameLayout and an ImageButton

http://developer.android.com/reference/android/widget/VideoView.html

You can use it to play videos of certain file types in your res/raw folder.

This is kind of a hack: You can have a VideoView in a FrameLayout with an ImageButton on one of the upper frames. When the user clicks the ImageButton you can remove the ImageButton and start playing the video in the VideoView

If it wasn't clear, ImageButton holds the snapshot of the video. You can assign whichever image you wish, of course.

You can find the supported media types here:

http://developer.android.com/guide/appendix/media-formats.html

I would recommend 3gp since it is compressed.

Community
  • 1
  • 1
Dheeraj Bhaskar
  • 18,633
  • 9
  • 63
  • 66