VideoView:双击全屏
基本上,我想要在我的应用程序中执行的操作是显示视频。
实现这一目标的最佳工具似乎是 VideoView。
所以我在我的 Activity 中使用了这段代码
<VideoView android:id="@+id/videoview" android:layout_width="50dip" android:layout_height="50dip"></VideoView>
:
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();
就可以了。
不幸的是,我期望默认情况下在我的布局中有视频预览(缩略图)
,所以我删除了 videoHolder.start();命令,但我只能得到黑屏。点击不可见区域时视频开始...
第一个问题
是否可以在开始之前在 VideoView 中显示视频预览?
第二个问题
我想在双击网页视图时全屏显示视频,我怎样才能实现这一点?
非常感谢任何帮助/链接/建议
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,您可以使用 ThumbnailUtils 获取视频缩略图:
我还没有真正使用过以前见过应用程序切换到全屏。我实际上不确定它是否可以完成(特别是对于
VideoView
)。但是,您可能会幸运地使用以下方法之一:VideoView
保存在FrameLayout
中,然后更改其布局参数。Window#addContentView
覆盖VideoView
。Visibility.GONE
)您的其他视图并允许VideoView
扩展其布局区域。Yes, you can get video thumbnails using ThumbnailUtils:
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:VideoView
in aFrameLayout
and then changing its layout parameters.VideoView
viaWindow#addContentView
.Visibility.GONE
) your other views and allowing theVideoView
to expand its layout area.您可以使用 VideoView.seekTo(milliseconds) 作为替代方案,假设 1 秒(1000 毫秒)。假设 1 秒后的视频剪辑确实有图像,例如某些视频从空白屏幕开始,然后“淡入”(缺乏更好的词)到某个场景,则更经常会出现 1 秒黑屏。您可以在 VideoView.onPrepared() 下调用它。当视频位于网络服务器上时我使用这个。
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.