通过当前视图在Android中播放视频
我想知道是否可以在不离开活动的情况下在当前视图上播放视频。就像一个带有模糊效果的对话框 这有可能吗?或者你知道任何图书馆吗 我没有找到任何东西 非常感谢通过当前视图在Android中播放视频,android,android-videoview,Android,Android Videoview,我想知道是否可以在不离开活动的情况下在当前视图上播放视频。就像一个带有模糊效果的对话框 这有可能吗?或者你知道任何图书馆吗 我没有找到任何东西 非常感谢 将以下库添加到app build.gradle compile 'com.sherazkhilji.videffects:videffects:1.0.2' 在您的布局中 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
compile 'com.sherazkhilji.videffects:videffects:1.0.2'
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.sherazkhilji.videffects.view.VideoSurfaceView
android:id="@+id/mVideoSurfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#a0000000">
//your layout goes here
</LinearLayout>
</RelativeLayout>
compile 'com.sherazkhilji.videffects:videffects:1.0.2'
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.sherazkhilji.videffects.view.VideoSurfaceView
android:id="@+id/mVideoSurfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#a0000000">
//your layout goes here
</LinearLayout>
</RelativeLayout>
我最终通过一个简单的对话解决了这个问题
final Dialog dialog = new Dialog(ActQuiz.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.myvideoview);
dialog.show();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.copyFrom(dialog.getWindow().getAttributes());
dialog.getWindow().setAttributes(lp);
uriPath= "android.resource://" + getPackageName() + "/" + R.raw.test;
mVideoView.setVideoURI(Uri.parse(uriPath));
mVideoView.start();
我最终通过一个简单的对话解决了这个问题
final Dialog dialog = new Dialog(ActQuiz.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.myvideoview);
dialog.show();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.copyFrom(dialog.getWindow().getAttributes());
dialog.getWindow().setAttributes(lp);
uriPath= "android.resource://" + getPackageName() + "/" + R.raw.test;
mVideoView.setVideoURI(Uri.parse(uriPath));
mVideoView.start();