I want to assign a preview image of the video from a URL. After pressing Play, it should disappear and show the video. I have searched for info but I have not found anything, please if anyone has any more extensive information on the subject. Thank you!
My code:
val mPlayer: SimpleExoPlayer
val inflater = activity?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val contenedor: View = inflater.inflate(R.layout.nota_exoplayer_container, null)
val playerView: PlayerView = contenedor.findViewById(R.id.exoPlayer)
playerView.useController = true
playerView.requestFocus()
val bandwidthMeter: BandwidthMeter = DefaultBandwidthMeter()
val videoTrackSelectionFactory: TrackSelection.Factory = AdaptiveTrackSelection.Factory(bandwidthMeter)
val trackSelector: TrackSelector = DefaultTrackSelector(videoTrackSelectionFactory)
mPlayer = ExoPlayerFactory.newSimpleInstance(activity.applicationContext, trackSelector)
playerView.player = mPlayer
val fullScreenBtn = playerView.findViewById<ImageView>(R.id.exo_fullscreen_icon)
val defaultBandwidthMeter = DefaultBandwidthMeter()
val dataSourceFactory: DataSource.Factory = DefaultDataSourceFactory(
activity.applicationContext,
Util.getUserAgent(activity.applicationContext, "VID"),
defaultBandwidthMeter)
val mediaSource = ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url))
mPlayer.prepare(mediaSource)
My layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/exoContainer"
android:orientation="vertical"
style="@style/ajustar_al_padre">
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/exoPlayer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>