title: In ExoPlayer, how exactly to use SimpleExoPlayer.setVideoScalingMode to be like in ImageView center-crop?
body: <h2>Background</h2>
  
  <p>I'm trying to have a video shown in center-crop manner (like on ImageView).</p>
  
  <p>I also hope I can find how to scale in other ways, as done on <a href="https://github.com/yqritc/Android-ScalableVideoView" rel="nofollow noreferrer"><strong>this library</strong></a>.</p>
  
  <h2>The problem</h2>
  
  <p>I use this for this purpose : </p>
  
  <pre><code>    player!!.videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING
  </code></pre>
  
  <p>But for some reason it doesn't do center-cropping.</p>
  
  <h2>What I've tried</h2>
  
  <p>Looking at the docs, I see this:</p>
  
  <p>"Note that the scaling mode only applies if a MediaCodec-based video Renderer is enabled and if the output surface is owned by a SurfaceView."</p>
  
  <p>So I tried to set this in the XML file:</p>
  
  <pre><code>     app:surface_type="surface_view"
  </code></pre>
  
  <p>but it also didn't help. I don't see it available in code, either.</p>
  
  <p>I tried to search for anything with "renderer" or "codec" for this class, but none exist.</p>
  
  <p>Here's the code I use (based on this: <a href="https://github.com/yusufcakmak/ExoPlayerSample" rel="nofollow noreferrer">https://github.com/yusufcakmak/ExoPlayerSample</a> ) :</p>
  
  <pre><code>class MainActivity : AppCompatActivity() {
      val VIDEO_URL = "https://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4"
      private var player: SimpleExoPlayer? = null
  
      private var window: Timeline.Window? = null
      private var mediaDataSourceFactory: DataSource.Factory? = null
      private var trackSelector: DefaultTrackSelector? = null
      private var shouldAutoPlay: Boolean = false
      private var bandwidthMeter: BandwidthMeter? = null
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          shouldAutoPlay = true
          bandwidthMeter = DefaultBandwidthMeter()
          mediaDataSourceFactory = DefaultDataSourceFactory(this, Util.getUserAgent(this, "mediaPlayerSample"), bandwidthMeter as TransferListener&lt;in DataSource&gt;)
          window = Timeline.Window()
      }
  
      private fun initializePlayer() {
          if (player != null)
              return
          simpleExoPlayerView.requestFocus()
          val videoTrackSelectionFactory = AdaptiveTrackSelection.Factory(bandwidthMeter)
          trackSelector = DefaultTrackSelector(videoTrackSelectionFactory)
          player = ExoPlayerFactory.newSimpleInstance(this, trackSelector)
          simpleExoPlayerView.player = player
          player!!.repeatMode = Player.REPEAT_MODE_ALL
          player!!.playWhenReady = shouldAutoPlay
          player!!.videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING
          val extractorsFactory = DefaultExtractorsFactory()
          val mediaSource = ExtractorMediaSource(Uri.parse(VIDEO_URL), mediaDataSourceFactory, extractorsFactory, null, null)
          player!!.prepare(mediaSource)
      }
  
      private fun releasePlayer() {
          if (player != null) {
              shouldAutoPlay = player!!.getPlayWhenReady()
              player!!.release()
              player = null
              trackSelector = null
          }
      }
  
      public override fun onStart() {
          super.onStart()
          if (Util.SDK_INT &gt; 23) {
              initializePlayer()
          }
      }
  
      public override fun onResume() {
          super.onResume()
          if (Util.SDK_INT &lt;= 23 || player == null) {
              initializePlayer()
          }
      }
  
      public override fun onPause() {
          super.onPause()
          if (Util.SDK_INT &lt;= 23) {
              releasePlayer()
          }
      }
  
      public override fun onStop() {
          super.onStop()
          if (Util.SDK_INT &gt; 23) {
              releasePlayer()
          }
      }
  }
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;com.google.android.exoplayer2.ui.SimpleExoPlayerView
      android:id="@+id/simpleExoPlayerView" xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"
      android:focusable="true" app:surface_type="surface_view"/&gt;
  </code></pre>
  
  <p><strong>manifest</strong></p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  </code></pre>
  
  <p><strong>gradle file</strong></p>
  
  <pre><code>implementation 'com.google.android.exoplayer:exoplayer:r2.5.2'
  </code></pre>
  
  <h2>The questions</h2>
  
  <ol>
  <li><p>What's wrong in what I did?</p></li>
  <li><p>What is exactly the first requirement? </p></li>
  <li><p>I think this version of the SDK is a bit old. How should I update it ? Maybe it's a bug and it got fixed ? </p></li>
  </ol>