VideoView: Fullscreen on DoubleTap

Basically, what I want to do in my application is a video.

The best tool to achieve this, apparently, is VideoView.

So, I used this code:

<VideoView android:id="@+id/videoview" android:layout_width="50dip" android:layout_height="50dip"></VideoView> 

and in my activity:

  VideoView videoHolder = (VideoView)findViewById(R.id.videoview); videoHolder.setMediaController(new MediaController(this)); videoHolder.setVideoURI(Uri.parse("android.resource://com.blabla.blabla/" + R.raw.blabla)); videoHolder.requestFocus(); videoHolder.start(); 

and that does the trick.

Unfortunately, I was expecting a preview (thumbnail) of the video in my default layout

So, I deleted videoHolder.start () ;, but I can only get a black screen. The video starts when you click on the invisible zone ...

First question

Is it possible to display a preview of a video in VideoView before launching it?

Second question

I liked displaying the video on Fullscreen by double-clicking on the web view, how can I achieve this?

Thanks a lot for any help / link / suggestion

+4
source share
2 answers

Yes, you can get thumbnails of the video using ThumbnailUtils :

 Bitmap thumb = ThumbnailUtils.createVideoThumbnail(path, MediaStore.Images.Thumbnails.MINI_KIND); 

I have not seen before how applications switch to full screen mode. Actually, I'm not sure if this can be done (especially for VideoView ). However, you might be lucky with one of these methods:

  • Saving VideoView to FrameLayout , and then changing its layout settings.
  • Overlay VideoView on Window#addContentView .
  • Hiding (via Visibility.GONE ) your other views and the ability of VideoView to expand its placement.
+3
source

You can use VideoView.seekTo (milliseconds) as an alternative, say 1 second (1000 milliseconds). Provided that the video has an image after 1 second, for example, some videos start from a blank screen, then β€œfade” (lack of a better word) will often produce a black screen with a second on the scene. You can call this under VideoView.onPrepared (). This one I use when the video is on a web server.

0
source

Source: https://habr.com/ru/post/1347782/


All Articles