'RTSP Streaming with Exoplayer in android studio

I want to stream an RTSP stream using exoplayer in android. I am new to android developer.I have put all dependencies in gradle file. But I am getting error in this code

       package com.androidbegin.video_stream;

    import androidx.appcompat.app.AppCompatActivity;

   import android.net.Uri;
   import android.os.Bundle;


  import com.google.android.exoplayer2.SimpleExoPlayer;

   import com.google.android.exoplayer2.source.rtsp.RtspMediaSource;

import com.google.android.exoplayer2.ui.PlayerView;

import com.google.android.exoplayer2.source.rtsp.RtspDefaultClient;
import com.google.android.exoplayer2.source.rtsp.RtspMediaSource;
import com.google.android.exoplayer2.source.rtsp.core.Client;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;

public class MainActivity extends AppCompatActivity {


PlayerView playerView;
SimpleExoPlayer player = null;

private Boolean playWhenReady = true;
private int currentWindow = 0;
private Long playbackPosition = 0L;

DefaultBandwidthMeter defaultBandwidthMeter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    playerView = findViewById(R.id.player_view);
    defaultBandwidthMeter = new DefaultBandwidthMeter();

    if (player == null) {
        player = ExoPlayerFactory.newSimpleInstance(MainActivity.this);//Cannot resolve symbol'ExoPlayerFactory
        playerView.setPlayer(player);
    }
    String url = "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov";
    RtspMediaSource videoSource = new RtspMediaSource
            .Factory(RtspDefaultClient.factory()    //cannot resolve symbol RtspDefaultClient
            .setFlags(Client.FLAG_ENABLE_RTCP_SUPPORT)//cannot resolve symbol client
            .setNatMethod(Client.RTSP_NAT_DUMMY))
            .createMediaSource(Uri.parse(url));

    player.prepare(videoSource, true, false);
    player.setPlayWhenReady(true);
}

@Override
protected void onStart(){
    super.onStart();

}

@Override
protected void onStop(){
    super.onStop();

    if(player!=null){
        playbackPosition = player.getContentPosition();
        currentWindow = player.getCurrentWindowIndex();
        playWhenReady = player.getPlayWhenReady();

        playerView.setPlayer(null);
        player.release();
        player = null;
    }
}


}

my error is

C:\Users\Administrator\AndroidStudioProjects\video_stream\app\src\main\java\com\androidbegin\video_stream\MainActivity.java:15:

error: cannot find symbol
import com.google.android.exoplayer2.source.rtsp.RtspDefaultClient;
import com.google.android.exoplayer2.source.rtsp.core.Client;

my implementations are

Blockquote

implementation "com.google.android.exoplayer:exoplayer-rtsp:2.17.1"
implementation "com.google.android.exoplayer:exoplayer-core:2.17.1"
implementation "com.google.android.exoplayer:exoplayer-dash:2.17.1"
implementation "com.google.android.exoplayer:exoplayer-ui:2.17.1"


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source