2017-04-16 8 views
0

활동을 떠나지 않고 현재보기에서 비디오를 재생할 수 있는지 알고 싶습니다. 흐린 효과가있는 AlertDialog와 같습니다.현재 Android에서 비디오 재생보기

라이브러리가있을 수 있습니까?

나는 그걸 찾지 못했습니다.

미리 감사드립니다.

답변

2

마침내 간단한 Dialog로 해결했습니다.

0
  1. 은 자바 클래스 자바 측에서 레이아웃

    <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> 
    

3에서

compile 'com.sherazkhilji.videffects:videffects:1.0.2' 
  • build.gradle 응용 프로그램 당신에게 다음과 같은 라이브러리를 추가

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        playVdo(); 
    } 
    
    @Override 
    protected void onResume() { 
        super.onResume(); 
        mVideoView.onResume(); 
    } 
    
    @Override 
    protected void onPause() { 
        super.onPause(); 
        mVideoView.onPause(); 
    } 
    
    private MediaPlayer mMediaPlayer; 
    private Resources mResources; 
    private VideoSurfaceView mVideoView; 
    
    private void playVdo() { 
        mResources = getResources(); 
        mMediaPlayer = new MediaPlayer(); 
        mMediaPlayer.setScreenOnWhilePlaying(true); 
        mMediaPlayer.setVolume(0, 0); 
        try { 
         AssetFileDescriptor afd = getAssets().openFd("login_vdo.mp4"); 
         mMediaPlayer.setDataSource(afd.getFileDescriptor(), 
           afd.getStartOffset(), afd.getLength()); 
        } catch (Exception e) { 
         Log.e("mMediaPlayer", e.getMessage(), e); 
        } 
        mVideoView = (VideoSurfaceView) findViewById(R.id.mVideoSurfaceView); 
        mVideoView.init(mMediaPlayer, 
          new DocumentaryEffect()); 
    }