"android-video Playback" Utility Vitamio custom control bar Position

Source: Internet
Author: User

In the development, the use of video playback function, see the online ready-made open-source Vitamio has been very mature. The spirit of take doctrine is directly practical.

But the position of the practical progress bar in play is sometimes not as consistent with your own needs.

Here is the tutorial

1. First modify the Mediacontroller class in Vitamio, add a constructor to this class, and the code is as follows:

Public Mediacontroller (Context Context,boolean Fromxml,view container) {super (context); Initcontroller (context); Mfromxml = Fromxml;mroot = Makecontrollerview ();
This place is framelayout.layoutpparams because the layout file is to add Mediacontroller view as Childview to a framelayout framelayout.layoutparams p = new Framelayout.layoutparams (layoutparams.fill_parent, layoutparams.wrap_content);// How to layout mediacontroller to enjoy the Layoutparams bar p.gravity = Gravity.bottom;mroot.setlayoutparams (p);((framelayout) Container). AddView (Mroot);}

All the fields used in this method are original, no new code is added

2. Define the XML layout file that plays the video, with the following code:

<framelayout android:id= "@+id/ll" android:layout_width= "fill_parent" android:layout_height= "Wrap_c            Ontent "android:visibility=" Gone "> <linearlayout android:layout_width=" fill_parent " android:layout_height= "Wrap_content" android:background= "@color/black" android:orientation= "ver Tical "> <io.vov.vitamio.widget.centerlayout android:id=" @+id/cl "android:l Ayout_width= "Fill_parent" android:layout_height= "wrap_content" android:background= "@color/BL Ack "> <io.vov.vitamio.widget.videoview android:id=" @+id/vv "an Droid:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layou T_centerhorizontal= "true" android:layout_centervertical= "true"/> </io.vov.vitamio.wid Get.    Centerlayout>    </LinearLayout> </FrameLayout> 

Used in 3.Activity

/**
* First parameter: Current context
* Second parameter: Be sure to be true in order to execute some code in Mediacontroller
* The third parameter: which view to add the controller to
*/

Mediacontroller mc = new Mediacontroller (this,true,llvideo); Vv.setmediacontroller (MC); Mc.setvisibility (View.GONE) This operation is to solve the problem that the control bar does not move when the video is turned on, and you need to click the video to move around. This way the user does not see the progress bar by default, and when you click on the video you can see the progress bar that is moving.

I hope we can help some people.

Play

"android-video Playback" Utility Vitamio custom control bar Position

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.