Android MediaController seekbar chapter markers? - android

I am currently working on a simple video player on Android OS 2.3.3 where I am using a VideoView to display a movie and using the MediaController to control the video.
I want to add a few chapter markers along the seekbar and was wondering if anyone has any ideas on how to go about doing this?

Just use horizontal SeekBar instead of MediaController.
Put it in RelativeLayout and behind SeekBar set some views which will be chapter markers. This markers will be visible if they will be little bit bigger than SeekBar height. You can add this View's programmatically when needed by calculating their positions depend on video duration and seekbar length.
Of course layout can be little bit more complicated.

Related

how to display a scrolling Text ticker on a video played using textureview

Iam playing a video using android textureview , my requirement is to add a text ticker at the bottom of the video, the ticker consists of a live 3d backgroundstrip over which text scrolls . how to draw a live 3d background at the bottom of the texture view that is already playing a video ie., the ticker should be like an overlay to the video . I have tried calling the surface again and apply set tranform on it but the original video size is also change . Can some one please tell me howto go about. thank you

How to create overlay video widget like has YouTube application?

I'm creating application with video widget that has fullscreen feature.
My approach is, that I have got main FrameLayout and when I toggle fullscreen I add black background and VideoView widget into this layout.
The problem with my approach is, that change of View structure where is VideoView stored causes MediaPlayer to restart playback, therefore video gets rebuffered - lag in playing.
Possible solution
Create overlay widget/layer, where is video played and resize this overlay to fullscreen or position it over area where should be video played. If I'm not wrong. This won't cause invalidation of canvas, like it is when is videoview moved in view hierarchy. Therefore video should continue play like in new youtube application (android 4.3).
Unfortunately, I'm not Android master, just beginner with Android and this is my first more complex application. So, I can't implement this on my own and I also want to another overlay where is video controller placed and this overlay shall be placed over videoview overlay.

Frame-by-frame animation or video animation?

I need to use animations in the app. Is it better to use frame-to-frame ImageView animations or to use video animations? Video animations are SWF (which I can probably convert to mp4).
The animations last up to 4s what would be around 80 images in one frame-to-frame animation. This is the layout of the app.
A different animation will appear in the red area based on which button on the right side is pressed.
Now, which approach is best to use?
I know that frame-to-frame approach may create an app with a lot of MBs.
I also do not know if video approach could make smooth animations? Can I play SWF files inside the such layout or I would have to convert each into mp4 in order to use this app on pre-Android-2.2 mobile phones.
Please advise!
For an ImageView, I assume you will be doing the animation by repeatedly calling the invalidate method. This will not give you a high frame rate. To do real-time animation, you need a SurfaceView or subclass thereof, perhaps a VideoView.

Hide video but have it continue to play

I have an image and a video player. In portrait, it shows both. Doing landscape left, just the video shows. Doing landscape right just the image shows.
I am using the setVisibility() method right now to achieve that. The problem with doing:
myVideoView.setVisibility(View.INVISIBLE);
causes the video to stop playing. Is there a way to keep it playing but also not visible to the user? Maybe like set the opacity of the VideoView to 0?
I think I found a solution here. In order to make videoview invisible and keep it playing sound you simply hide it by setting alpha value.
mVideoView.setAlpha(0f);
Hope it works for you!
You could try changing the z-order of the views with the bringToFront() method.
If you want the video to show then call mVideoView.bringToFront() and when you want the image to show you could use mImageView.bringToFront() this should work as long as the video and the image both occupy the same space on the screen.
Good luck

Android VideoView plays 2 videos at the same time

I am trying to play a videoview on top of another video view. The first video view is paused, while the second is playing. It appears to work but no second video appears on the screen (though I hear the audio and see the controls that would normally appear on top). I am assuming this is some sort of order issue. Any thoughts. By the way, I have no problem displaying other views on top of the main video view and having the video fill the background.
That won't work - the VideoView is special in the sense that it 'punches' a hole in the normal Views to allow direct access to the display pixels (or, in android terms, the 'Surface' - VideoView is a subclass of SurfaceView). You cannot layer two SurfaceViews on top of eachother - the first one that grabs the pixels (the Surface) will 'own' it. (see SurfaceHolder.Callback.surfaceCreated() / surfaceDestroyed())
Other Views on top of a SurfaceView do work, because the framework will compose the display bits of normal Views on top of the Surface. It cannot do that with another VideoView (i.e. a SurfaceView) because there is nothing to compose.
<VideoView android:id="#+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<VideoView android:id="#+id/videoView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
when videoView2 starts playing setvisibilty of videoView1 invisible.
then you can make it visible when you need.
Use Thread to control both video
I don't know if this is helpful at the moment, but I managed to get something similar to what you want...
I needed to nest a VideoView on top of a SurfaceView; as long as they don't overlap 100% it can work. (what i mean is, my surfaceview is the whole screen and videoview is just a small portion of the screen)
The thing is - since you can't compose SurfaceViews, the first one to grab the pixels is the one that will be shown. Intuitiveness will drive you to Z-order your prioritized view AFTER the less-important one in the XML - but as I've said previously, the first one to grab the pixels stays, so make sure you define the smaller view FIRST, and then overlay it with the bigger one.
This will result in such behaviour that the smaller (in my case preview view) acquires the said X * Y pixels, and then the 'background' surfaceview (which is supposed to be on top of it according to the XML) takes up the rest and ignores the smaller surface.
I'm not too sure about handling events from those two though as I only have to play streams in those two views and not react to any kind of clicks/events generated by those two components, but it might be expected that if you followed this route - the bigger view will intercept all clicks made in the smaller view area (because it's on top according to the XML) so maybe you have to programatically move it on top as well upon creation.
Hope it helps.
EDIT:
Although... it like it just works once. It's a work in progress really. Upon returning from any activity, there's nothing i can do to prevent the bigger view claiming everything :/
you can add videoview a on top videoview b,like this,
parentview.removeview(a);
parentview.removviewe(b);
parentview.addview(a);
parentview.addview(b);
parentview.invalidate();
Ti's work for me. I hope it can helps.

Categories

Resources