1 year ago

#173838

test-img

Anshul Tyagi

VideoView unable to play video using an url

I'm trying to play a video using a url but it's not working. It always give me error on screen as Can't play this video.

I'm using below snippet:

   val uri: Uri = Uri.parse(it.url)
   binding.videoView.setVideoURI(uri)
   val mediaController = MediaController(activity)
   mediaController.setAnchorView(binding.videoView)
   mediaController.setMediaPlayer(binding.videoView)
   binding.videoView.setMediaController(mediaController)
   binding.videoView.setOnPreparedListener { binding.videoView.start() }

Logcat Error:

 E/MediaPlayerNative: error (1, -1015)
 E/MediaPlayer: Error (1,-1015)

I'm getting the YouTube url mostly. Thanks in advance.

android

android-videoview

0 Answers

Your Answer

Accepted video resources