我正在使用视频查看youtube / rtmp直播视频应用程序并从网络上搜索示例代码所以秋天我让应用程序正常工作但是当我改变方向时我遇到问题现场视频旋转并扩展精细但它没有进入完整的全屏幕,只有当我进入横向模式时,如何才能设置完全全屏的方式?
我的主要活动。
progressdialog = ProgressDialog.show(this, "", " Cargando vídeo por favor espere...", true);
progressdialog.setCancelable(true);
final VideoView vidView = (VideoView)findViewById(R.id.video_view);
String vidAddress = "http://videourl/playlist.m3u8";
Uri vidUri = Uri.parse(vidAddress);
vidView.setVideoURI(vidUri);
MediaController vidControl = new MediaController(this);
vidControl.setAnchorView(vidView);
vidView.setMediaController(vidControl);
vidView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer arg0) {
progressdialog.dismiss();
vidView.start();
}
});
main xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white" >
<GridView
android:id="@+id/list_playlist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/video_view"
android:layout_margin="5sp"
android:gravity="center"
android:numColumns="2"
android:scrollbars="none" >
</GridView>
<RelativeLayout
android:id="@+id/layout_ad"
android:layout_width="match_parent"
android:layout_height="50sp"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal" >
</RelativeLayout>
<VideoView
android:id="@+id/video_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"/>
答案 0 :(得分:0)
在OrientationChange
事件或任何事件将视频发送至fullscreen
时,您必须隐藏 Status Bar
和Action Bar
。这样,当您更改方向时,状态栏和操作栏将被隐藏,允许视频全屏显示。
如何隐藏状态栏:
1。 See this from Android Developer
如何隐藏操作栏:
希望这可以帮到你。
答案 1 :(得分:0)
我已经设法通过应用以下代码解决了这个问题,但仍然没有完全全屏。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
}
setContentView(R.layout.activity_main);
答案 2 :(得分:0)
将规则设置为像这样的视频帧
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == ORIENTATION_LANDSCAPE){
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) rel.getLayoutParams();
lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, R.id.relativeFrame);
lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, R.id.relativeFrame);
lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, R.id.relativeFrame);
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, R.id.relativeFrame);
rel.setLayoutParams(lp);
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
记得在配置更改回prtrait时删除规则
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) rel.getLayoutParams();
lp.removeRule(RelativeLayout.ALIGN_PARENT_TOP);
lp.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
lp.removeRule(RelativeLayout.ALIGN_PARENT_LEFT);
lp.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rel.setLayoutParams(lp);
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE;
decorView.setSystemUiVisibility(uiOptions);
}