List of usage examples for android.widget VideoView requestFocus
public final boolean requestFocus()
From source file:Main.java
/** * Play video file from res folder./*from w w w. j a v a2 s . c om*/ * Then call video.start(); * @param activity - current Activity * @param videoViewId R.id.introVideo * @param videoResourceId R.raw.intro - res/raw/intro.mp4 * @return VideoView */ public static VideoView playVideo(Activity activity, int videoViewId, int videoResourceId, MediaPlayer.OnCompletionListener listener) { activity.getWindow().setFormat(PixelFormat.TRANSLUCENT); VideoView view = (VideoView) activity.findViewById(videoViewId); view.setVideoURI( Uri.parse("android.resource://" + activity.getPackageName() + File.separator + videoResourceId)); view.setKeepScreenOn(true); view.setMediaController(null); view.setOnCompletionListener(listener); view.requestFocus(); return view; }
From source file:com.ternup.caddisfly.activity.VideoActivity.java
private void playVideo(File videoFile) { DisplayMetrics dm = new DisplayMetrics(); this.getWindowManager().getDefaultDisplay().getMetrics(dm); int height = dm.heightPixels; int width = dm.widthPixels; final VideoView videoHolder = (VideoView) this.findViewById(R.id.video_player_view); videoHolder.setMinimumWidth(width);/* w w w .j av a 2 s. c om*/ videoHolder.setMinimumHeight(height); //getWindow().setFormat(PixelFormat.TRANSLUCENT); videoHolder.setMediaController(new MediaController(this)); videoHolder.setVideoPath(videoFile.getAbsolutePath()); videoHolder.requestFocus(); videoHolder.start(); }
From source file:com.javierarboleda.visualtilestogether.activities.SignInActivity.java
private void initTutorialView() { mPager = (ViewPager) findViewById(R.id.tutorial_view_pager); mPager.setAdapter(new TutorialImageAdapter(this)); TabLayout tabLayout = (TabLayout) findViewById(R.id.tutorial_tab_layout); tabLayout.setupWithViewPager(mPager, true); mTimer = new Timer(); mTimer.scheduleAtFixedRate(new RemindTask(), 0, 4000); mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override//from w w w . ja v a 2 s . c o m public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { mPage = position; } @Override public void onPageSelected(int position) { } @Override public void onPageScrollStateChanged(int state) { } }); Animation animation = new AlphaAnimation(0f, 1f); animation.setDuration(1400); findViewById(R.id.ivTutorial).startAnimation(animation); findViewById(R.id.tutorial_view_pager).startAnimation(animation); findViewById(R.id.tutorial_tab_layout).startAnimation(animation); findViewById(R.id.view_footer).startAnimation(animation); final VideoView videoView = (VideoView) findViewById(R.id.vvTutorialVideo); videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video_tutorial_1)); videoView.requestFocus(); videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mediaPlayer) { videoView.seekTo(0); videoView.start(); } }); videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mediaPlayer) { videoView.seekTo(0); videoView.start(); } }); }