resize media player in android - android

I have been Created the app which contains default android media player with surfaceView. I can resize the Video , but not able to resize the media player for modify the height and with of play/pause button. In that I having 2 doubt.
Whether can I inflate any custom layout to replace that default media player.
Is it possible to convert MediaController to View or ViewGroup .
or else, Is there any possibility to setLayoutParams() for mediaController in code not in xml?
Any have an idea?
Please help me!.
Thanks in advance.
Regards,
ThiloG.

You can use your layout that will represent play, stop and pause (for instance) buttons. You just put it on your layout on the bottom. I didn't understand you very well, but this will do the work...

Related

Fullscreen VideoView button

I'm currently using a VideoView together with MediaController and I wonder if there is a simple way to add a fullscreen button mode.
That would be a button, on the MediaController bar or somewhere else on the top of the VideoView, that on click, would display the video on a full screen mode.
(Btw, I am very amazed that Android did not add this as a default controller on the MediaController!!!)
Thanks in advance.
In my application I removed the VideoView from its parent and set it at the content view.
Here as a basic idea (could contain small errors):
VideoView video = (VideoView)findViewById(...);
((ViewGroup)video.getParent()).removeChild(video);
setContentView(video);
By the way depending on your target platform I would suggest to use the TextureView.

Create custom media player like Youtube in Android

I have to create media player like youtube player.Actually if i use VideoView for play video and MediaController for controll video(MediaController onlyu provides play,pause,next,pre and seek options).But in my player i have to add one more option i.e bandwidth(I would have three bandwidth and on clicking on bandwidth video will play).So please suggest me.
As far I know, MediaController doesn't give many opportunities to be customized. So, you have two options depending on your UI requirements and the effort you are willing to do.
The hard way: You can just get rid of Android MediaController and
implement your own media controller, since you are not bound to use
it. MediaPlayer (through VideoView) provides you the needed
functions to build it: pause(), play(), resume() methods and event
listeners like onPrepared, onStopped, etc. To display the progress
bar you can use SeekBar, but you will have to code the interaction
with MediaPlayer (this is, the progress bar will not move alone).
The easy way: you can find another place to put your bandwith
button, for instance, on the top of the screen. You might even place
your button over MediaController.
You just have to create a layout properly combining the GUI elements you need. VideoView can be used with other GUI elements like buttons and can be nested within layouts like RelativeLayout and LinearLayout.
So, if you want your bandwidth button adjacent to VideoView, you may use LinearLayout, if you want your bandwith button over the video surface, like MediaController, you may use RelativeLayout, managing properly the layers.
have a look at SurfaceView, that will give you an idea on not bounding your logic with player.

Android -- View Over Media Player

I wanted to build an application that will allow user to share comments about any video while they watch them. For that I require a View over the Media Player view.
Can anyone please guide me how we can achieve this?
You can have a FrameLayout or a RelativeLayout and stack the View you want over the MediaPlayer View.
Hope this helps!

Android MediaController intercepts all other touch events

The top half of my app has a VideoView with a MediaController under it. The bottom half is an image with some buttons. While the MediaController is visible, the buttons below are not clickable. It's like while the MediaController is visible, it intercepts all other touch events, even if they are not within the bounds of the MediaController.
Any idea around that?
You can check out my answer on overriding dispatchTouchEvent() to pass clicks through MediaController to an underlying Button, but I'm guessing there's something wrong with the way you use MediaController. Can you post your layout?
UPD:
Actually, strike that. I've just taken a look at MediaController code and it turns out it creates a new Window for itself. That's why your clicks don't get dispatched — they're dispatched to another window. Also, as far as I can tell from the constructor code, if you inflate the MediaController via xml (i.e. use it in a layout file and then just find it by id from you code) — it won't create the extra Window. That's weird, but I'm sure they had reasons for that.
So, the solution is to either try to use MediaController in a layout file or go with CommonsWare's solution. Please, let me know how it goes in case you give the xml thing a try.
Any idea around that?
Do not use MediaController. Create your own controller UI that you pop up and display as needed. While this sample project may no longer completely work, as I have not touched in three years, it demonstrates having your own controller panel that pops up on a touch and then goes away.
Could you supply your VideoView instantiation code and the code you use to switch out the MediaPlayers?
In any case, I doubt this will work well because the VideoView instantiates its own MediaPlayer and uses it to play media. (see VideoView.java)
You would probably need to switch out the VideoView itself, or build a replacement for the VideoView using your own subclass of SurfaceView.
I have face same issue, my UI element block due to media player, After spend 5 hours I got solution
I just replace mediaPlayer.prepare() to mediaPlayer.prepareAsync();

Is it possible to creating a custom Videoplayer and place it in a View on Android?

I have been searching around for any info on creating a video player. Here is what I am looking for, I want to create a player to play videos (stream preferably) with my own custom playback buttons. The player will be set in a View (size of the view varies). Can i do this with just the MediaPlayer class, and can i add it in a View. If there are any examples or tutorials. I would greatly appreciate it. Thankx again in advance
the most straight forward way of controlling a video is using the mediaController class:
http://developer.android.com/reference/android/widget/MediaController.html
This can ether be anchored to a mediaPlayer or a VideoView. Both of these support streaming and since mediaController is a Widget it can be customized.
This should be enough unless you looking to do something really out there with the controller.
Hope this helps

Categories

Resources