[英]Video not going Fullscreen on Android
I want my video activity to go fullscreen when the video starts, but it's not happening.我希望我的视频活动在视频开始时全屏显示,但它没有发生。 Here are some screenshots and the code that runs this activity.:
以下是一些屏幕截图和运行此活动的代码。:
public class InfoLentes extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.infolentes);
}
public void sendMessage(View view) {
setContentView(R.layout.fullscreen);
VideoView VideoView = new VideoView(this);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
VideoView.setMediaController(new MediaController(this));
Uri video = Uri.parse("android.resource://" + getPackageName() + "/"
+ R.raw.eyeprotect);
VideoView.setVideoURI(video);
setContentView(VideoView);
VideoView.start();
}
}
And this is my fullscreem.xml这是我的 fullscreem.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:id="@+id/VideoViewfull"
android:layout_width="match_parent"
android:layout_height="match_parent">
</VideoView>
</FrameLayout>
And Screenshots of whats happening.:以及正在发生的事情的截图。:
What am I doing wrong?我究竟做错了什么?
EDIT:编辑:
So Using @Sheetal Kumar Maurya answer, I created another activity and used the android:theme="@style/AppTheme.NoActionBar" on the manifest, the result is better, but still not really fullscreen.:所以使用@Sheetal Kumar Maurya 的答案,我创建了另一个活动并在清单上使用了 android:theme="@style/AppTheme.NoActionBar",结果更好,但仍然不是真正的全屏:
Create a VideoPlayer activity with NoActionbar theme.创建一个带有 NoActionbar 主题的 VideoPlayer 活动。
<activity
android:name=".VideoPlayerActivity"
android:theme="@style/AppTheme.NoActionBar" />
In onCreate section add following:在 onCreate 部分添加以下内容:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Now use this activity as a player for full screen and enjoy.现在将此活动用作全屏播放器并享受。
So I finally, after a long time of searching, found the perfect solution for my problem.因此,经过长时间的搜索,我终于找到了解决我问题的完美解决方案。 Using the answer here on this post from @Hamiseixas, I did the following.:
使用@Hamiseixas 在这篇文章中的答案,我做了以下事情:
Edited Gradle, and synced:编辑 Gradle,并同步:
compile 'com.github.rtoshiro.fullscreenvideoview:fullscreenvideoview:1.1.2'
repositories {
mavenCentral()
}
Instead of a videoview, I used the new compiled package on my fullscreen.xml:我在 fullscreen.xml 上使用了新编译的包,而不是视频视图:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_height="fill_parent">
<com.github.rtoshiro.view.video.FullscreenVideoLayout
android:id="@+id/videoview"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</com.github.rtoshiro.view.video.FullscreenVideoLayout>
</RelativeLayout>
And when I press the intent button to take me to the video file I want to play, this is the activity that playes it.:当我按下意图按钮将我带到我想播放的视频文件时,这是播放它的活动。:
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.github.rtoshiro.view.video.FullscreenVideoLayout;
import java.io.IOException;
public class VideoTest extends AppCompatActivity {
FullscreenVideoLayout videoLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fullscreen);
videoLayout = (FullscreenVideoLayout) findViewById(R.id.videoview);
videoLayout.setActivity(this);
Uri video = Uri.parse("android.resource://" + getPackageName() + "/"
+ R.raw.eyeprotect);
try {
videoLayout.setVideoURI(video);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
}
It was that simple =D就这么简单=D
It's all better documented here , a huge thanks to that post, and to the creator of FullscreenVideoView, Toshiro在这里记录得更好,非常感谢那篇文章,以及 FullscreenVideoView 的创建者Toshiro
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.