Java Code Examples for org.videolan.libvlc.IVLCVout#setWindowSize()
The following examples show how to use
org.videolan.libvlc.IVLCVout#setWindowSize() .
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: VlcVideoLibrary.java From vlc-example-streamplayer with GNU General Public License v3.0 | 5 votes |
private void setMedia(Media media) { //delay = network buffer + file buffer //media.addOption(":network-caching=" + Constants.BUFFER); //media.addOption(":file-caching=" + Constants.BUFFER); if (options != null) { for (String s : options) { media.addOption(s); } } media.setHWDecoderEnabled(true, false); player = new MediaPlayer(vlcInstance); player.setMedia(media); player.setEventListener(this); IVLCVout vlcOut = player.getVLCVout(); //set correct class for render depend of constructor called if (surfaceView != null) { vlcOut.setVideoView(surfaceView); width = surfaceView.getWidth(); height = surfaceView.getHeight(); } else if (textureView != null) { vlcOut.setVideoView(textureView); width = textureView.getWidth(); height = textureView.getHeight(); } else if (surfaceTexture != null) { vlcOut.setVideoSurface(surfaceTexture); } else if (surface != null) { vlcOut.setVideoSurface(surface, surfaceHolder); } else { throw new RuntimeException("You cant set a null render object"); } if (width != 0 && height != 0) vlcOut.setWindowSize(width, height); vlcOut.attachViews(); player.setVideoTrackEnabled(true); player.play(); }
Example 2
Source File: VLCPlayerView.java From react-native-vlc-player with MIT License | 4 votes |
private void changeSurfaceSize(int width, int height) { int screenWidth = width; int screenHeight = height; mVideoWidth = width; mVideoHeight = height; mVideoVisibleWidth = width; mVideoVisibleHeight = height; if (mMediaPlayer != null) { final IVLCVout vlcVout = mMediaPlayer.getVLCVout(); vlcVout.setWindowSize(screenWidth, screenHeight); } double displayWidth = screenWidth, displayHeight = screenHeight; if (screenWidth < screenHeight) { displayWidth = screenHeight; displayHeight = screenWidth; } // sanity check if (displayWidth * displayHeight <= 1 || mVideoWidth * mVideoHeight <= 1) { return; } // compute the aspect ratio double aspectRatio, visibleWidth; if (mSarDen == mSarNum) { /* No indication about the density, assuming 1:1 */ visibleWidth = mVideoVisibleWidth; aspectRatio = (double) mVideoVisibleWidth / (double) mVideoVisibleHeight; } else { /* Use the specified aspect ratio */ visibleWidth = mVideoVisibleWidth * (double) mSarNum / mSarDen; aspectRatio = visibleWidth / mVideoVisibleHeight; } // compute the display aspect ratio double displayAspectRatio = displayWidth / displayHeight; counter++; switch (mCurrentSize) { case SURFACE_BEST_FIT: if (counter > 2) if (displayAspectRatio < aspectRatio) displayHeight = displayWidth / aspectRatio; else displayWidth = displayHeight * aspectRatio; break; case SURFACE_FIT_HORIZONTAL: displayHeight = displayWidth / aspectRatio; break; case SURFACE_FIT_VERTICAL: displayWidth = displayHeight * aspectRatio; break; case SURFACE_FILL: break; case SURFACE_16_9: aspectRatio = 16.0 / 9.0; if (displayAspectRatio < aspectRatio) displayHeight = displayWidth / aspectRatio; else displayWidth = displayHeight * aspectRatio; break; case SURFACE_4_3: aspectRatio = 4.0 / 3.0; if (displayAspectRatio < aspectRatio) displayHeight = displayWidth / aspectRatio; else displayWidth = displayHeight * aspectRatio; break; case SURFACE_ORIGINAL: displayHeight = mVideoVisibleHeight; displayWidth = visibleWidth; break; } // set display size int finalWidth = (int) Math.ceil(displayWidth * mVideoWidth / mVideoVisibleWidth); int finalHeight = (int) Math.ceil(displayHeight * mVideoHeight / mVideoVisibleHeight); SurfaceHolder holder = mSurface.getHolder(); holder.setFixedSize(finalWidth, finalHeight); ViewGroup.LayoutParams lp = mSurface.getLayoutParams(); lp.width = finalWidth; lp.height = finalHeight; mSurface.setLayoutParams(lp); mSurface.invalidate(); }