android 视频播放 旋转,Android:视频视图在旋转后不会播放。

I have an activity that show half of the screen facing user and the other half facing another guy in opposite direction. The portion facing another guy has a video view. Like this:

我有一个活动,显示一半的屏幕面向用户,另一半面向另一个相反方向的人。面对另一个人的部分有一个视频视图。是这样的:

aHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS81NFFvSS5wbmc=

In my activity layout, I have:

在我的活动布局中,我有:

android:id="@+id/LinearLayout1"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

android:id="@+id/scrollViewTop"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_margin="10dp"

android:layout_weight="1"

android:scrollbars="none"

android:rotation="180.0" >

......

android:id="@+id/videoView1"

android:layout_width="75dp"

android:layout_height="75dp" />

......

android:layout_width="match_parent"

android:layout_height="100dp"

android:orientation="vertical" >

I use following code to set the video view: (videofile.mp4)

我使用以下代码来设置视频视图:(videofile.mp4)

videoView1 = (VideoView) findViewById(R.id.videoView1);

Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.videofile);

videoView1.setVideoURI(video);

videoView1.start();

It show a black screen without the video playing. Other content is showing correctly in 180 degree rotation except the video playback.

它显示了一个没有视频播放的黑色屏幕。除视频播放外,其他内容在180度旋转时显示正确。

However, if I remove the line android:rotation="180.0" the video is playing correctly.

但是,如果我删除线android:旋转="180.0"视频播放正确。

Is there a way to play the video while the screen is rotated?

当屏幕旋转时,有办法播放视频吗?

1 个解决方案

#1

0

Haven't got any luck finding the proper solution. I use a walk-around instead.

没有找到合适的解决办法。我用散步代替。

First apply a rotation to the video view within the parent rotation.

首先对父旋转中的视频视图进行旋转。

android:layout_width="75dp" android:layout_height="75dp" android:旋转="180.0" />。

This will cause the layout to become:

这将导致布局成为:

aHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS94WnZ2MC5wbmc=

Then we output the video source (videofile.mp4) to play in 180 degrees.

然后我们输出视频源(videofile.mp4),播放180度。

With 1 + 2, it is "as if" the video is playing in the other direction.

在1 + 2的情况下,“好像”这个视频在另一个方向播放。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值