2

I m using VideoView to display video.

My Requirement is a MediaController wid play/Pause, Stop, & Volume Contoller.. i tried

         MediaController mc = new MediaController(this);  
         View mMediaControllerView = (View)findViewById(R.id.mediaController1); 
         mc.setAnchorView(mMediaControllerView);
         videoView.setMediaController(mc);

adding an imageview to the layout but this seems to have no effect on the MediaController

need some guidance/hint to proceed further...

Thanks.

Nital
  • 975
  • 3
  • 9
  • 15
  • 1
    Here is an example MediaController customization: http://stackoverflow.com/questions/12482203/how-to-create-custom-ui-for-android-mediacontroller/14323144#14323144 – Blago Jan 14 '13 at 17:16

3 Answers3

6

You have to write the MediaController Class all over again extending a FrameLayout .The Layout that it uses should be customised. Get the copy from android source code of MediaController Class and then proceed ahead.

Arun
  • 2,800
  • 23
  • 13
  • 1
    It refers to internal class PolicyManager which cannot be imported... how to resolve that? – Jasper Jan 20 '15 at 14:28
1

My "solution" was to not set a MediaController for the VideoView. I just created a separate MediaController class that is its own class and did all the custom drawing. This class was just copied from the source code of the real MediaController. In the constructor of my custom MediaController I pass the VideoView and store a reference so I can interact with the VideoView (VideoView has all the methods you need to interact with the MediaPlayer: getCurrentPosition(), getDuration(), resume(), pause(), seekTo(), ...). Let me know if you need more help with it.

Joris Weimar
  • 4,783
  • 4
  • 33
  • 53
  • 1
    Hi Joris. Have you a functional example, and you are inflating from XML this Custom Media Controller? Your solution can allow free position in layout? I need set the position inside of a videoview aligned to left in a relative layout. – ClarkXP Apr 18 '12 at 21:56
  • Sorry I didn't get back to you sooner. You still need this info? I'm not inflating the custom controller. I just made my own media controller class (it just inherits from Object). You pass it a VideoView object as a mentioned. There is no XML involved. – Joris Weimar Jun 20 '12 at 18:46
  • @JorisWeimar I also want to create own MediaController Class. please share your source. Thank you! – Dhasneem Jun 05 '13 at 11:34
-1

This should be enough:

MediaController mc = new MediaController(this);  
mc.setMediaPlayer(videoView);
videoView.setMediaController(mc);
ania
  • 2,352
  • 1
  • 20
  • 20
  • MediaController by default has fastFWD, rewind, & play/Pause.. my req is differnt, so i wanna customize it – Nital Jul 21 '11 at 06:49
  • Sorry, didn't understand you. If you want to customize it, you have to write your own. Unfortunately, there are no additional methods for developers. But it's easy, you can take sources of MC and customize it(there are lot of topics on stackoverflow about it) or write your own (mostly using videoview listners). – ania Jul 21 '11 at 06:55
  • initially wat i want is i wanna customize layout of MC.. i did it using xml Layout, wid the code specified, but the look & feel of MC dint change.. So if u can correct that... – Nital Jul 21 '11 at 08:28
  • @Nital what a consistent reply from ania! *-* – ruben Apr 27 '13 at 22:28