Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DetailVideoKajianActivity : AppCompatActivity() {
- private lateinit var binding: ActivityDetailVideoKajianBinding
- companion object {
- const val EXTRA_VIDEO_KAJIAN = "extra_video_kajian"
- }
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- binding = ActivityDetailVideoKajianBinding.inflate(layoutInflater)
- val view = binding.root
- setContentView(view)
- val video = intent.getParcelableExtra<VideoKajianModel>(EXTRA_VIDEO_KAJIAN)
- as VideoKajianModel
- initView(video)
- }
- private fun initView(video: VideoKajianModel) {
- val youtubePlayerView: YouTubePlayerView = findViewById(R.id.player_video)
- lifecycle.addObserver(youtubePlayerView)
- youtubePlayerView.addYouTubePlayerListener(object : AbstractYouTubePlayerListener() {
- override fun onReady(youTubePlayer: YouTubePlayer) {
- youTubePlayer.loadVideo(video.urlVideo, 0f)
- }
- })
- binding.tvChannel.text = video.channel
- binding.tvTitle.text = video.title
- binding.tvSpeaker.text = video.speaker
- binding.tvSummary.text = video.summary
- binding.ivShare.setOnClickListener {
- val sendIntent = Intent()
- sendIntent.action = Intent.ACTION_SEND
- sendIntent.putExtra(Intent.EXTRA_TEXT,
- "Kajian dengan judul \"${video.title}\" dibawakan oleh \"${video.speaker}\" dan dari channel \"${video.channel}\" \n\n\n Link Video : https://www.youtube.com/watch?v=${video.urlVideo}"
- )
- sendIntent.type = "text/plain"
- startActivity(sendIntent)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement