I use PlayerView
to play mp4 video file, but the first frame always stretch to full screen. How can we avoid that? This is code I config Player
and PlayerView
player = SimpleExoPlayer.Builder(requireContext()).build().apply {
playWhenReady = this@VideoPlayerFragment.playWhenReady
seekTo(currentWindow, playbackPosition)
setMediaSource(mediaSource, false)
prepare()
}
video_view.player = player
i had android:animateLayoutChanges="true"
in StyledPlayerView tag which caused the problem, remove it. also make sure parent view doesn't have animateLayoutChanges
attribute
here is the full exoplayer xml
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:animation_enabled="false"
app:auto_show="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:repeat_toggle_modes="none"
app:resize_mode="fit"
app:show_timeout="3000"
app:surface_type="texture_view"
app:use_controller="true" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.