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.
1 Answers
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.

- 1
- 1

- 18,633
- 9
- 63
- 66
-
Hi, @DheeB , is there any other way to accomplish the task? For some reason, I don't wanna try this API. – injoy Feb 11 '14 at 17:12
-
@injoy updated with an alternate way of approaching this – Dheeraj Bhaskar Feb 12 '14 at 08:00
-
is this the standard way to accomplish the task? Besides, how to retrieve the 'image' from a remote video according the URL? – injoy Feb 12 '14 at 21:21