Videoview不是在牛轧糖24中显示,而是在android Q 29中显示和工作

Videoview不是在牛轧糖24中显示,而是在android Q 29中显示和工作,android,android-layout,android-videoview,android-fullscreen,Android,Android Layout,Android Videoview,Android Fullscreen,我在申请工作。当点击按钮时,它会显示带有视频视图的弹出窗口。它在Android29API中显示,但在Android24API中不显示。下面是它的showvideopopup功能代码 private void showVideoPopup() { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View cu

我在申请工作。当点击按钮时,它会显示带有视频视图的弹出窗口。它在Android29API中显示,但在Android24API中不显示。下面是它的showvideopopup功能代码

private void showVideoPopup()
    {
        LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View customView = layoutInflater.inflate(R.layout.dispensing_intro,null);

        int uiOptions =View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        customView.setSystemUiVisibility(uiOptions);


//        closePopupBtn = (Button) customView.findViewById(R.id.closeView);

        //instantiate popup window
        dispense_intro_popup = new PopupWindow(customView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        //display the popup window
        dispense_intro_popup.showAtLocation(dispense_intro_view, Gravity.CENTER, 0, 0);

        VideoView video = (VideoView) customView.findViewById(R.id.dispense_intro);
        Uri videoUri = Uri.parse("android.resource://" + getPackageName() + "/raw/"+ R.raw.dispense_intro);
        video.setVideoURI(videoUri);
        video.start();

        video.setOnCompletionListener(this);

    }
下面是popup.xml文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:background="#b3000000"
    android:layout_height="700dp"
    android:id="@+id/dispense_intro_holder"
    android:layout_gravity="center"
    android:gravity="center">


    <VideoView
        android:id="@+id/dispense_intro"
        android:layout_gravity="center"
        android:layout_width="640dp"
        android:layout_height="360dp"  />
</LinearLayout>

使用
DialogFragment()
而不是
PopupWindow

然后将以下代码添加到片段
onCreateView

PopupFragment.java

 public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.popup, container, false);
        setStyle(DialogFragment.STYLE_NO_TITLE, R.style.FullscreenTheme);
        VideoView video = (VideoView) rootView.findViewById(R.id.dispense_intro);
        Uri videoUri = Uri.parse("android.resource://" + getPackageName() + "/raw/"+ R.raw.dispense_intro);
        video.setVideoURI(videoUri);
        video.start();

        video.setOnCompletionListener(this);

        return rootView;

}
要使对话框片段全屏显示,请使用以下代码创建
onDialogCreated

public Dialog onCreateDialog(Bundle savedInstanceState) {
        Dialog dialog = super.onCreateDialog(savedInstanceState);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

        dialog.getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_IMMERSIVE
                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        // Hide the nav bar and status bar
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN);
        return dialog;
    }
使用
DialogFragment()
而不是
PopupWindow

然后将以下代码添加到片段
onCreateView

PopupFragment.java

 public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.popup, container, false);
        setStyle(DialogFragment.STYLE_NO_TITLE, R.style.FullscreenTheme);
        VideoView video = (VideoView) rootView.findViewById(R.id.dispense_intro);
        Uri videoUri = Uri.parse("android.resource://" + getPackageName() + "/raw/"+ R.raw.dispense_intro);
        video.setVideoURI(videoUri);
        video.start();

        video.setOnCompletionListener(this);

        return rootView;

}
要使对话框片段全屏显示,请使用以下代码创建
onDialogCreated

public Dialog onCreateDialog(Bundle savedInstanceState) {
        Dialog dialog = super.onCreateDialog(savedInstanceState);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

        dialog.getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_IMMERSIVE
                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        // Hide the nav bar and status bar
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN);
        return dialog;
    }

2个问题,
1
您是否看到任何错误/跟踪?还是干脆不播放任何视频?在调用
.start()
之前,请尝试记录视频URI是什么,看看这是否因任何原因而不同。不,我没有看到任何堆栈跟踪。我可以记录视频uri@Silmarilos请调查这两个问题,
1
您是否发现任何错误/痕迹?还是干脆不播放任何视频?在调用
.start()
之前,请尝试记录视频URI是什么,看看这是否因任何原因而不同。不,我没有看到任何堆栈跟踪。我可以记录视频uri@Silmarilos请调查一下这件事好吗