I know there are ways using TextureViews and some other ways, but can we do a video flip in a VideoView, I tried using the method scaleType of X axis to -1, but just getting a black screen. Is there no way to do a simple video flip for a video being played in a videoview? Am I forced to use a TextureView or other methods?
As you said, the best option is to use TextureView... Android's VideoView can only play videos straight and not mirrored.
If you want your app to play a video mirrored (for instance if the video was recorded using a front camera), you will need to use a TextureView, which can be easily mirrored by specifying android:scaleX=-1 in the XML file, or textureView.setScaleX(-1) in the code. (source)
Related
I'm trying to use a VideoPlayer component, with a URL source and a RenderTexture as the target, to show a video in my Unity mobile game. The video is loaded and starts playing, however the resulting texture is only 1 color. The color does change every frame to something matching what the video would look like that frame, but it's just the 1 color. Audio is working fine. On the VideoPlayer component, the Aspect Ratio is set to "Fit Inside", but I have tried all options here with the same result. As for the RenderTexture, it's set to the same resolution as the input video, and the Color Format is set to RGB565 (which both Android and iOS should support according to SystemInfo.SupportRenderTextureFormat()). I'm all out of ideas, any help would be appreciated.
EDIT: A workaround could be using "material override" instead of rendering to a texture. This doesn't work though if you want to use the texture specifically instead of only showing the video on a material, plus the fact that Material Override doesn't support objects with multiple renderers/materials. Not really a fix, but a workaround for those who find this question before a solution has been found.
I just had this myself and fixed it.
In the Raw Image, search UV Rect and set its W and H to 1. I had changed that, which made it only sample 1 pixel.
When I play a video file using a VideoView on Android, I can hear the sound fine, but the video does not show.
So, when I use :
myVideoView.setZOrderOnTop(true);
then the video shows fine, however, then my TextView is behind the VideoView and I need it to be in front.
Therefore, I either need a solution so that the video is played without using setZOrderOnTop, or I need a way to get the text in front of the video while using setZOrderOnTop.
videoView.setBackgroundColor(Color.TRANSPARENT);
I would like to append several video files from the camera through mp4parser.
Unfortunately, in the same fragment, despite the fact that I try to change the OrientationHint of the media recorder when changing camera, only the first one seems to work (ie. if I start with the front camera, the videos with the back camera are reversed and vice versa).
To solve this problem, I tried to rotate the video that are in the wrong direction and that works (with the method of setMatrix mp4parser, the new files are in good direction). But when I want to append the files, (all in the right direction) I get the same result as if I had not rotated the videos, as if it could have only one orientation videos for my final component video.
Do you have a solution for this?
Thanks
I am using Vitamio media player to play RTMP stream onto a SurfaceView, everything is fine but the video size is smaller than the screen. I am looking for a way to scale the video to fit the entire screen. I set the SurfaceHolder to the fixed size of my Nexus4 display (1280*720) and the video received is (950*640).
I tried overriding onDraw but no results.
I am trying now to override unlockCanvasAndPost function of SurfaceHolder, so I can scale the canvas, but don't know exactly how to achieve this.
Also, maybe there are related AVoptions I can pass to the player?
You can scale the video surface, VitamioDemo have a sample, https://github.com/yixia/VitamioBundle/blob/master/vitamio-sample/src/io/vov/vitamio/demo/VideoViewSubtitle.java
Basically, what I want to do in my application is displaying a video.
The best tool to achieve this goal seem to be a 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 do the trick.
Unfortunately, I was expecting having a preview (thumbnail) of the video in my layout by default
So , I removed the videoHolder.start(); command, but I can only get a blackscreen. The video start when tapping on an invisible zone...
First question
Is that possible to display a preview of the video in the VideoView before starting it?
Second question
I wuld like to display the video on Fullscreen when double tapping the webview, How can I achieve this?
Thank a lot for any help / link / suggestion
Yes, you can get video thumbnails using ThumbnailUtils:
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(path,
MediaStore.Images.Thumbnails.MINI_KIND);
I haven't really seen apps toggle into fullscreen before. I'm actually not sure if it can be done (especially for a VideoView). However, you might have some luck with one of these methods:
Holding the VideoView in a FrameLayout and then changing its layout parameters.
Overlaying the VideoView via Window#addContentView.
Hiding (via Visibility.GONE) your other views and allowing the VideoView to expand its layout area.
You can use VideoView.seekTo(milliseconds) as an alternative, let say 1 second (1000 milliseconds). Provided that the video clip after 1 second does have an image, like some videos starts from blank screen then "fade-in" (lack of better word) to a scene would more often gives you a black screen with 1 second. You can call this under VideoView.onPrepared(). This one i use when the video is on a web server.