class YoutubeDetail : AppCompatActivity() {
private lateinit var binding: ActivityYoutubeDetailBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityYoutubeDetailBinding.inflate(layoutInflater)
setContentView(binding.root)
var url = intent.getStringExtra("video")
var playerPosition = 0
val mediaController = MediaController(this)
with(binding.videoView) {
this.setVideoPath(url)
this.requestFocus()
this.start()
mediaController.show()
}
binding.stop.setOnClickListener {
binding.videoView.pause()
playerPosition = binding.videoView.currentPosition
}
binding.start.setOnClickListener {
binding.videoView.seekTo(playerPosition)
binding.videoView.start()
}
}
}