Advertisement
AzisMM

DetailVideoKajianActivity.kt

Nov 1st, 2021
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.72 KB | None | 0 0
  1. class DetailVideoKajianActivity : AppCompatActivity() {
  2.  
  3.     private lateinit var binding: ActivityDetailVideoKajianBinding
  4.  
  5.     companion object {
  6.         const val EXTRA_VIDEO_KAJIAN = "extra_video_kajian"
  7.     }
  8.  
  9.     override fun onCreate(savedInstanceState: Bundle?) {
  10.         super.onCreate(savedInstanceState)
  11.         binding = ActivityDetailVideoKajianBinding.inflate(layoutInflater)
  12.         val view = binding.root
  13.         setContentView(view)
  14.  
  15.         val video = intent.getParcelableExtra<VideoKajianModel>(EXTRA_VIDEO_KAJIAN)
  16.                 as VideoKajianModel
  17.  
  18.         initView(video)
  19.     }
  20.  
  21.     private fun initView(video: VideoKajianModel) {
  22.         val youtubePlayerView: YouTubePlayerView = findViewById(R.id.player_video)
  23.         lifecycle.addObserver(youtubePlayerView)
  24.  
  25.         youtubePlayerView.addYouTubePlayerListener(object : AbstractYouTubePlayerListener() {
  26.             override fun onReady(youTubePlayer: YouTubePlayer) {
  27.                 youTubePlayer.loadVideo(video.urlVideo, 0f)
  28.             }
  29.         })
  30.  
  31.         binding.tvChannel.text = video.channel
  32.         binding.tvTitle.text = video.title
  33.         binding.tvSpeaker.text = video.speaker
  34.         binding.tvSummary.text = video.summary
  35.  
  36.         binding.ivShare.setOnClickListener {
  37.             val sendIntent = Intent()
  38.             sendIntent.action = Intent.ACTION_SEND
  39.             sendIntent.putExtra(Intent.EXTRA_TEXT,
  40.                 "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}"
  41.             )
  42.             sendIntent.type = "text/plain"
  43.             startActivity(sendIntent)
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement