Java Code Examples for android.widget.VideoView#setLayoutParams()
The following examples show how to use
android.widget.VideoView#setLayoutParams() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JCameraView.java From Tok-Android with GNU General Public License v3.0 | 6 votes |
private void initVideoView() { /*VideoView 播放视频的界面*/ mVideoView = new VideoView(mContext); LayoutParams videoViewParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); videoViewParam.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); mVideoView.setLayoutParams(videoViewParam); this.addView(mVideoView); //viedoView mVideoView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mCamera.autoFocus(JCameraView.this); } }); }
Example 2
Source File: MainActivity.java From example with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); videoView = (VideoView) findViewById(R.id.videoview); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) videoView.getLayoutParams(); params.width = metrics.widthPixels; params.height = metrics.heightPixels; videoView.setLayoutParams(params); videoView.setVideoURI( Uri.parse("android.resource://" + getPackageName() + "/raw/" + R.raw.momentss)); videoView.start(); // looping videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mediaPlayer) { mediaPlayer.setLooping(true); } }); }
Example 3
Source File: Utils.java From tv-samples with Apache License 2.0 | 5 votes |
/** * Example for handling resizing content for overscan. Typically you won't need to resize when * using the Leanback support library. */ public void overScan(Activity activity, VideoView videoView) { DisplayMetrics metrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); int w = (int) (metrics.widthPixels * MediaDimensions.MEDIA_WIDTH); int h = (int) (metrics.heightPixels * MediaDimensions.MEDIA_HEIGHT); int marginLeft = (int) (metrics.widthPixels * MediaDimensions.MEDIA_LEFT_MARGIN); int marginTop = (int) (metrics.heightPixels * MediaDimensions.MEDIA_TOP_MARGIN); int marginRight = (int) (metrics.widthPixels * MediaDimensions.MEDIA_RIGHT_MARGIN); int marginBottom = (int) (metrics.heightPixels * MediaDimensions.MEDIA_BOTTOM_MARGIN); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(w, h); lp.setMargins(marginLeft, marginTop, marginRight, marginBottom); videoView.setLayoutParams(lp); }
Example 4
Source File: SimpleVideoStream.java From cordova-plugin-streaming-media with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); Bundle b = getIntent().getExtras(); mVideoUrl = b.getString("mediaUrl"); mShouldAutoClose = b.getBoolean("shouldAutoClose", true); mControls = b.getBoolean("controls", true); RelativeLayout relLayout = new RelativeLayout(this); relLayout.setBackgroundColor(Color.BLACK); RelativeLayout.LayoutParams relLayoutParam = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); relLayoutParam.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); mVideoView = new VideoView(this); mVideoView.setLayoutParams(relLayoutParam); relLayout.addView(mVideoView); // Create progress throbber mProgressBar = new ProgressBar(this); mProgressBar.setIndeterminate(true); // Center the progress bar RelativeLayout.LayoutParams pblp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); pblp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); mProgressBar.setLayoutParams(pblp); // Add progress throbber to view relLayout.addView(mProgressBar); mProgressBar.bringToFront(); setOrientation(b.getString("orientation")); setContentView(relLayout, relLayoutParam); play(); }
Example 5
Source File: Utils.java From androidtv-Leanback with Apache License 2.0 | 5 votes |
/** * Example for handling resizing content for overscan. Typically you won't need to resize when * using the Leanback support library. */ public void overScan(Activity activity, VideoView videoView) { DisplayMetrics metrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); int w = (int) (metrics.widthPixels * MediaDimensions.MEDIA_WIDTH); int h = (int) (metrics.heightPixels * MediaDimensions.MEDIA_HEIGHT); int marginLeft = (int) (metrics.widthPixels * MediaDimensions.MEDIA_LEFT_MARGIN); int marginTop = (int) (metrics.heightPixels * MediaDimensions.MEDIA_TOP_MARGIN); int marginRight = (int) (metrics.widthPixels * MediaDimensions.MEDIA_RIGHT_MARGIN); int marginBottom = (int) (metrics.heightPixels * MediaDimensions.MEDIA_BOTTOM_MARGIN); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(w, h); lp.setMargins(marginLeft, marginTop, marginRight, marginBottom); videoView.setLayoutParams(lp); }
Example 6
Source File: FullScreenVideoUtil.java From appinventor-extensions with Apache License 2.0 | 4 votes |
/** * Creates the dialog for displaying a fullscreen VideoView. * * @return The created Dialog */ public Dialog createFullScreenVideoDialog() { if (mFullScreenVideoBundle == null) Log.i("Form.createFullScreenVideoDialog", "mFullScreenVideoBundle is null"); mFullScreenVideoView = new VideoView(mForm); mFullScreenVideoHolder = new FrameLayout(mForm); mFullScreenVideoController = new CustomMediaController(mForm); mFullScreenVideoView.setId(mFullScreenVideoView.hashCode()); mFullScreenVideoHolder.setId(mFullScreenVideoHolder.hashCode()); mFullScreenVideoView.setMediaController(mFullScreenVideoController); mFullScreenVideoView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { Log.i("FullScreenVideoUtil..onTouch", "Video Touched!!"); return false; } }); mFullScreenVideoController.setAnchorView(mFullScreenVideoView); String orientation = mForm.ScreenOrientation(); if (orientation.equals("landscape") || orientation.equals("sensorLandscape") || orientation.equals("reverseLandscape")) { mFullScreenVideoView.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.FILL_PARENT, Gravity.CENTER)); } else { mFullScreenVideoView.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER)); } mFullScreenVideoHolder .setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); mFullScreenVideoHolder.addView(mFullScreenVideoView); // Add the MediaController to the Dialog mFullScreenVideoController.addTo(mFullScreenVideoHolder, mMediaControllerParams); mFullScreenVideoDialog.setContentView(mFullScreenVideoHolder); return mFullScreenVideoDialog; }