com.google.android.exoplayer2.ui.AspectRatioFrameLayout Java Examples
The following examples show how to use
com.google.android.exoplayer2.ui.AspectRatioFrameLayout.
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: AndExoPlayerView.java From MagicalExoPlayer with MIT License | 6 votes |
public void setResizeMode(EnumResizeMode resizeMode) { switch (resizeMode) { case FIT: playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT); break; case FILL: playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL); break; case ZOOM: playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_ZOOM); break; default: playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT); } }
Example #2
Source File: StreamFragment.java From Twire with GNU General Public License v3.0 | 6 votes |
private void setVideoViewLayout() { ViewGroup.LayoutParams layoutParams = rootView.getLayoutParams(); layoutParams.height = isLandscape ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT; ConstraintLayout.LayoutParams layoutWrapper = (ConstraintLayout.LayoutParams) mVideoWrapper.getLayoutParams(); if (isLandscape && !pictureInPictureEnabled) { layoutWrapper.width = mShowChatButton.getRotation() == 0 ? ConstraintLayout.LayoutParams.MATCH_PARENT : getScreenRect(getActivity()).height() - getLandscapeChatTargetWidth(); } else { layoutWrapper.width = ConstraintLayout.LayoutParams.MATCH_PARENT; } mVideoWrapper.setLayoutParams(layoutWrapper); AspectRatioFrameLayout contentFrame = mVideoWrapper.findViewById(R.id.exo_content_frame); if (isLandscape) { contentFrame.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT); } else { contentFrame.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIXED_WIDTH); } }
Example #3
Source File: MediaController.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void setTextureView(TextureView textureView, AspectRatioFrameLayout aspectRatioFrameLayout, FrameLayout container, boolean set) { if (textureView == null) { return; } if (!set && currentTextureView == textureView) { pipSwitchingState = 1; currentTextureView = null; currentAspectRatioFrameLayout = null; currentTextureViewContainer = null; return; } if (videoPlayer == null || textureView == currentTextureView) { return; } isDrawingWasReady = aspectRatioFrameLayout != null && aspectRatioFrameLayout.isDrawingReady(); currentTextureView = textureView; if (pipRoundVideoView != null) { videoPlayer.setTextureView(pipRoundVideoView.getTextureView()); } else { videoPlayer.setTextureView(currentTextureView); } currentAspectRatioFrameLayout = aspectRatioFrameLayout; currentTextureViewContainer = container; if (currentAspectRatioFrameLayoutReady && currentAspectRatioFrameLayout != null) { if (currentAspectRatioFrameLayout != null) { currentAspectRatioFrameLayout.setAspectRatio(currentAspectRatioFrameLayoutRatio, currentAspectRatioFrameLayoutRotation); } //if (currentTextureViewContainer.getVisibility() != View.VISIBLE) { // currentTextureViewContainer.setVisibility(View.VISIBLE); //} } }
Example #4
Source File: CustomExoPlayerView.java From leafpicrevived with GNU General Public License v3.0 | 5 votes |
public CustomExoPlayerView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); boolean useTextureView = false; int resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT; int rewindMs = CustomPlayBackController.DEFAULT_REWIND_MS; int fastForwardMs = CustomPlayBackController.DEFAULT_FAST_FORWARD_MS; int controllerShowTimeoutMs = CustomPlayBackController.DEFAULT_SHOW_TIMEOUT_MS; LayoutInflater.from(context).inflate(R.layout.exo_player, this); componentListener = new ComponentListener(); layout = findViewById(R.id.video_frame); layout.setResizeMode(resizeMode); shutterView = findViewById(R.id.shutter); subtitleLayout = findViewById(R.id.subtitles); subtitleLayout.setUserDefaultStyle(); subtitleLayout.setUserDefaultTextSize(); controller = findViewById(R.id.control); controller.hide(); controller.setRewindIncrementMs(rewindMs); controller.setFastForwardIncrementMs(fastForwardMs); this.controllerShowTimeoutMs = controllerShowTimeoutMs; View view = useTextureView ? new TextureView(context) : new SurfaceView(context); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); view.setLayoutParams(params); surfaceView = view; layout.addView(surfaceView, 0); }
Example #5
Source File: ExoPlayerFragment.java From carstream-android-auto with Apache License 2.0 | 5 votes |
public void setAspectRatio(WebViewCarFragment.AspectRatio aspectRatio) { if (aspectRatio == WebViewCarFragment.AspectRatio.CONTAIN) { playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT); } else if (aspectRatio == WebViewCarFragment.AspectRatio.FILL) { playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL); } else if (aspectRatio == WebViewCarFragment.AspectRatio.COVER) { playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_ZOOM); } }
Example #6
Source File: MediaController.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void setTextureView(TextureView textureView, AspectRatioFrameLayout aspectRatioFrameLayout, FrameLayout container, boolean set) { if (textureView == null) { return; } if (!set && currentTextureView == textureView) { pipSwitchingState = 1; currentTextureView = null; currentAspectRatioFrameLayout = null; currentTextureViewContainer = null; return; } if (videoPlayer == null || textureView == currentTextureView) { return; } isDrawingWasReady = aspectRatioFrameLayout != null && aspectRatioFrameLayout.isDrawingReady(); currentTextureView = textureView; if (pipRoundVideoView != null) { videoPlayer.setTextureView(pipRoundVideoView.getTextureView()); } else { videoPlayer.setTextureView(currentTextureView); } currentAspectRatioFrameLayout = aspectRatioFrameLayout; currentTextureViewContainer = container; if (currentAspectRatioFrameLayoutReady && currentAspectRatioFrameLayout != null) { if (currentAspectRatioFrameLayout != null) { currentAspectRatioFrameLayout.setAspectRatio(currentAspectRatioFrameLayoutRatio, currentAspectRatioFrameLayoutRotation); } //if (currentTextureViewContainer.getVisibility() != View.VISIBLE) { // currentTextureViewContainer.setVisibility(View.VISIBLE); //} } }
Example #7
Source File: YouTubePlayerV2Fragment.java From SkyTube with GNU General Public License v3.0 | 5 votes |
/** * Initialise the views. * * @param view Fragment view. */ private void initViews(View view) { // setup the toolbar / actionbar Toolbar toolbar = view.findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); // setup the player playerViewGestureHandler.initView(view); playerView.setOnTouchListener(playerViewGestureHandler); playerView.requestFocus(); setupPlayer(); playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT); // ensure that videos are played in their correct aspect ratio videoDescChannelThumbnailImageView.setOnClickListener(v -> { if (youTubeChannel != null) { SkyTubeApp.launchChannel(youTubeChannel, getActivity()); } }); commentsDrawer.setOnDrawerOpenListener(() -> { if (commentsAdapter == null) { commentsAdapter = new CommentsAdapter(getActivity(), youTubeVideo.getId(), commentsExpandableListView, commentsProgressBar, noVideoCommentsView); } }); this.playbackSpeedController= new PlaybackSpeedController(getContext(), playbackSpeedTextView, player); Linker.configure(this.videoDescriptionTextView); }
Example #8
Source File: ExoPlayerHelper.java From ExoPlayer-Wrapper with Apache License 2.0 | 5 votes |
private void removeThumbImageView() { if (mThumbImage != null) { AspectRatioFrameLayout frameLayout = mExoPlayerView.findViewById(R.id.exo_content_frame); frameLayout.removeView(mThumbImage); mThumbImage = null; } }
Example #9
Source File: ExoPlayerHelper.java From ExoPlayer-Wrapper with Apache License 2.0 | 5 votes |
private void setUiControllersVisibility(boolean visibility) { mExoPlayerView.setUseController(visibility); if (!visibility) { AspectRatioFrameLayout frameLayout = mExoPlayerView.findViewById(R.id.exo_content_frame); frameLayout.setOnClickListener(this); } }
Example #10
Source File: PlayerContainerView.java From Anecdote with Apache License 2.0 | 5 votes |
public void setVideoUrl(String url) { mVideoUrl = url; boolean needNewPlayer = mPlayer == null; if (needNewPlayer) { TrackSelection.Factory trackSelectionFactory = new FixedTrackSelection.Factory(); mTrackSelector = new DefaultTrackSelector(trackSelectionFactory); mPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), mTrackSelector); mPlayer.addListener(this); mPlayerView.setPlayer(mPlayer); mPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT); } // Produces DataSource instances through which media data is loaded. DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getContext(), Util.getUserAgent(getContext(), "unknown"), null); // Produces Extractor instances for parsing the media data. ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory(); // This is the MediaSource representing the media to be played. MediaSource videoSource = new ExtractorMediaSource(Uri.parse(url), dataSourceFactory, extractorsFactory, null, null); LoopingMediaSource loopingMediaSource = new LoopingMediaSource(videoSource); // Prepare the player with the source. mPlayer.prepare(loopingMediaSource); mPlayer.setVolume(0); mPlayerView.requestFocus(); mPlayer.setPlayWhenReady(true); // autoplay }
Example #11
Source File: CustomizePlayerView.java From bcm-android with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("ResourceType") private static void setResizeModeRaw(AspectRatioFrameLayout aspectRatioFrame, int resizeMode) { aspectRatioFrame.setResizeMode(resizeMode); }
Example #12
Source File: VideoPlayerActivity.java From ChatMessagesAdapter-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void adjustSurfaceView() { simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL); }
Example #13
Source File: SwipeablePlayerView.java From zapp with MIT License | 4 votes |
private boolean isZoomStateBoxed() { return getResizeMode() == AspectRatioFrameLayout.RESIZE_MODE_FIT; }
Example #14
Source File: SwipeablePlayerView.java From zapp with MIT License | 4 votes |
private boolean isZoomStateCropped() { return getResizeMode() == AspectRatioFrameLayout.RESIZE_MODE_ZOOM; }
Example #15
Source File: SwipeablePlayerView.java From zapp with MIT License | 4 votes |
private void setZoomStateBoxed() { setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT); settingsRepository.setIsPlayerZoomed(false); }
Example #16
Source File: SwipeablePlayerView.java From zapp with MIT License | 4 votes |
private void setZoomStateCropped() { setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_ZOOM); settingsRepository.setIsPlayerZoomed(true); }
Example #17
Source File: ExoVideoView.java From ExoVideoView with Apache License 2.0 | 4 votes |
@SuppressWarnings("ResourceType") private static void setResizeModeRaw(AspectRatioFrameLayout aspectRatioFrame, int resizeMode) { aspectRatioFrame.setResizeMode(resizeMode); }
Example #18
Source File: TubiExoPlayerView.java From TubiPlayer with MIT License | 4 votes |
@SuppressWarnings("ResourceType") private static void setResizeModeRaw(AspectRatioFrameLayout aspectRatioFrame, int resizeMode) { aspectRatioFrame.setResizeMode(resizeMode); }
Example #19
Source File: CustomizePlayerView.java From bcm-android with GNU General Public License v3.0 | 4 votes |
public void setAspectRatioListener(AspectRatioFrameLayout.AspectRatioListener listener) { Assertions.checkState(contentFrame != null); contentFrame.setAspectRatioListener(listener); }
Example #20
Source File: ExoVideoView.java From ExoVideoView with Apache License 2.0 | 2 votes |
/** * Sets the resize mode. * * @param resizeMode The resize mode. */ public void setResizeMode(@AspectRatioFrameLayout.ResizeMode int resizeMode) { Assertions.checkState(contentFrame != null); contentFrame.setResizeMode(resizeMode); }
Example #21
Source File: TubiExoPlayerView.java From TubiPlayer with MIT License | 2 votes |
/** * Sets the resize mode. * * @param resizeMode The resize mode. */ public void setResizeMode(@AspectRatioFrameLayout.ResizeMode int resizeMode) { Assertions.checkState(contentFrame != null); contentFrame.setResizeMode(resizeMode); }