VideoView在不同的屏幕尺寸 [英] VideoView in different screen sizes
问题描述
我试图插入不同尺寸屏幕的视频。我想这是一个很好的分辨率和不变形。我有2个视频为大型和小型屏幕。但我不知道如何将它们插入。
I'm trying to insert a video for different sizes of screen. What I want it's a good resolution and without distortion. I have 2 videos for large and tiny screens. But I don't know how to insert them.
我觉得这就像从可绘制文件(华电国际,LDPI等),您在您需要的分辨率文件夹中添加图像插入图片。 但我不知道如果发生在相同的视频或没有。
I thought it was like insert images from drawables files (hdpi, ldpi, etc) where you add the image in the resolution folder that you want. But I dont know if happens the same with videos or not.
请帮我同时插入视频,不同分辨率!
Please help me to insert both videos to different resolutions!
谢谢!
推荐答案
一个的绘制对象,尽可能的Android而言是任何一种图形/图像/图标...但是视频不属于这一类。对于这个问题,你必须将其放置在./assets/文件夹中。因此,影片不会自动根据屏幕尺寸选择。
A Drawable, as far as Android is concerned is any kind of graphic/image/icon... But a video doesn't fall in that category. For that matter, you'll have to place it at the "./assets/" folder. Therefore, videos aren't automatically selected according to the screen size.
然而,即使视频是在不同的文件夹中,可以通过编程在的onCreate()方法加载它们,像这样的:
However, even if the videos are in a different folder, you can load them programmatically at the onCreate() method, like this:
Display mDisplay = getWindowManager().getDefaultDisplay();
int w = mDisplay.getWidth();
int h = mDisplay.getHeight();
if (w < 480 || h < 800) {
mVideoView.setVideoPath(...your video in assets, of low resolution...);;
} else {
mVideoView.setVideoPath(...your video in assets, of high resolution...);
}
...
通过这种或类似的方法,您可以加载不同的视频,根据用户的分辨率,在某种程度上更是precise比LDPI / MDPI /等方式。
With this or a similar method, you can load different videos, according to the user resolution, in a way that is even more precise than the ldpi/mdpi/etc method.
这篇关于VideoView在不同的屏幕尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!