【问题标题】:Android Full screen videoviewAndroid 全屏视频查看
【发布时间】:2015-02-19 18:01:59
【问题描述】:

我想像 youtube 一样全屏视频缩小和扩大点击全屏视频点击全屏图像按钮我想视频全屏我使用片段。

我的 videoplayer.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/videolayout"
    android:layout_width="match_parent"
    android:layout_gravity="center"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:background="@android:color/black"
        android:gravity="center_horizontal" >


        <VideoView
            android:id="@+id/video_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center" />
    </LinearLayout>

    <ProgressBar
        android:id="@+id/progressbar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:visibility="gone" />

    <FrameLayout
        android:id="@+id/mediaController"
        android:layout_width="fill_parent"
        android:layout_height="80dp"
        android:layout_alignParentBottom="true"
        android:background="#80000000"
        android:visibility="gone" >


        <SeekBar
            android:id="@+id/seekBar1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:layout_marginTop="5dp"
          />

        <ImageButton
            android:id="@+id/btnpalypause"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center|bottom"
            android:layout_marginBottom="8dp"
             />

        <ImageButton
            android:id="@+id/fullscreen"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:layout_gravity="left|bottom"
              android:layout_marginBottom="5dp"
            android:layout_marginLeft="7dp"
            android:src="@drawable/maximize" />

    </FrameLayout>

</RelativeLayout>

只要在全屏图像按钮点击事件上告诉我我在做什么......

【问题讨论】:

    标签: android android-videoview


    【解决方案1】:

    全屏显示:

    点击全尺寸按钮后隐藏所有视频控制器视图。

    但您可以使用以下链接为您的电子管播放器:

    https://github.com/Jungerr/Demo-YouTuBe-Android

    我希望它对你有用。

    【讨论】:

    • 但是 yogendra 我想使用自定义播放器而不是 youtube 只是告诉我如何在我的活动中实现全屏功能.....
    • 或全屏使用横向并隐藏控制器等其他视图。
    • @Yogendra 我也尝试隐藏控制器和其他视图,但我的视频仍然没有以横向全屏显示
    【解决方案2】:

    我相信您问的是沉浸式可见性。

    您可以通过如下设置可见性来做到这一点:

    myView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE|View.SYSTEM_UI_FLAG_HIDE_NAVIGATION|View.SYSTEM_UI_FLAG_FULLSCREEN);
    

    请务必设置 OnSystemUiVisibilityChangeListener 以监控用户何时触摸屏幕或以其他方式强制自己退出全屏沉浸式模式。

    这也仅在 API 21 及更高版本中可用。

    要强制横向视图,请创建一个新活动并更新 AndroidManifest.xml 中的设置

    <activity android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:name="FullscreenVideoActivity" />
    

    然后通过使用空函数覆盖 FullScreenActivity.java 中的配置更改函数来阻止方向更改。

    @Override public void onConfigurationChanged(Configuration newConfig) 
    {      
       super.onConfigurationChanged(newConfig); 
    }
    

    【讨论】:

    • 是的,你明白我的意思....但是需要设置 SCREEN_ORIENTATION_LANDSCAPE ?
    • 为此,我将使用另一个仅包含视频视图的活动,并强制它在清单中横向显示。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多