Skip to content

Commit f1d0876

Browse files
committed
update: project
1 parent dd6a73b commit f1d0876

File tree

15 files changed

+128
-67
lines changed

15 files changed

+128
-67
lines changed

app/build.gradle

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ plugins {
44
}
55

66
android {
7-
compileSdk 32
7+
compileSdk 33
88

99
defaultConfig {
1010

1111
applicationId "com.frogobox.research"
1212
minSdk 21
13-
targetSdk 32
13+
targetSdk 33
1414
versionCode 1
1515
versionName "1.0"
1616

@@ -36,32 +36,33 @@ android {
3636
kotlinOptions {
3737
jvmTarget = JavaVersion.VERSION_11.toString()
3838
}
39+
namespace 'com.frogobox.research'
3940

4041
}
4142

4243
dependencies {
4344

44-
implementation "androidx.core:core-ktx:1.8.0"
45-
implementation "androidx.appcompat:appcompat:1.5.0"
45+
implementation "androidx.core:core-ktx:1.9.0"
46+
implementation "androidx.appcompat:appcompat:1.5.1"
4647
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
4748
implementation "androidx.work:work-runtime-ktx:2.7.1"
4849

49-
implementation "androidx.activity:activity-ktx:1.5.1"
50-
implementation "androidx.fragment:fragment-ktx:1.5.2"
50+
implementation "androidx.activity:activity-ktx:1.6.0"
51+
implementation "androidx.fragment:fragment-ktx:1.5.3"
5152

5253
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
5354
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
5455
implementation "androidx.lifecycle:lifecycle-livedata-core-ktx:2.5.1"
5556
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
5657
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1"
5758

58-
implementation "com.google.android.material:material:1.6.1"
59+
implementation "com.google.android.material:material:1.7.0"
5960

60-
implementation "com.google.android.exoplayer:exoplayer:2.17.1"
61-
implementation "com.google.android.exoplayer:exoplayer-core:2.17.1"
62-
implementation "com.google.android.exoplayer:exoplayer-dash:2.17.1"
63-
implementation "com.google.android.exoplayer:exoplayer-hls:2.17.1"
64-
implementation "com.google.android.exoplayer:exoplayer-ui:2.17.1"
61+
implementation "com.google.android.exoplayer:exoplayer:2.18.1"
62+
implementation "com.google.android.exoplayer:exoplayer-core:2.18.1"
63+
implementation "com.google.android.exoplayer:exoplayer-dash:2.18.1"
64+
implementation "com.google.android.exoplayer:exoplayer-hls:2.18.1"
65+
implementation "com.google.android.exoplayer:exoplayer-ui:2.18.1"
6566

6667
testImplementation "junit:junit:4.13.2"
6768
androidTestImplementation "androidx.test.ext:junit:1.1.3"

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
package="com.frogobox.research">
3+
xmlns:tools="http://schemas.android.com/tools">
54

65
<uses-permission android:name="android.permission.INTERNET" />
76

app/src/main/java/com/frogobox/research/MainActivity.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import android.os.Bundle
55
import androidx.appcompat.app.AppCompatActivity
66
import com.frogobox.research.databinding.ActivityMainBinding
77
import com.frogobox.research.exoplayer.WatchActivity
8+
import com.frogobox.research.util.Constant
89

910
class MainActivity : AppCompatActivity() {
1011

1112
companion object {
1213
val TAG = MainActivity::class.java.simpleName
14+
val VIDEO_URL = "https://www.youtube.com/watch?v=kRlF1zmWkYI&amp;list=PLLW55ltXv2-LqhgxSxIYocD8yAuLKX-kx&amp;index=9&amp;ab_channel=FaisalAmirTV"
15+
val VIDEO_TITLE = ""
1316
}
1417

1518
private val binding: ActivityMainBinding by lazy {
@@ -25,7 +28,10 @@ class MainActivity : AppCompatActivity() {
2528
private fun setupUI() {
2629
binding.apply {
2730
btnWatch.setOnClickListener {
28-
startActivity(Intent(this@MainActivity, WatchActivity::class.java))
31+
startActivity(Intent(this@MainActivity, WatchActivity::class.java).apply {
32+
putExtra(Constant.Extra.EXTRA_VIDEO_URL, VIDEO_URL)
33+
putExtra(Constant.Extra.EXTRA_VIDEO_TITLE, VIDEO_TITLE)
34+
})
2935
}
3036
}
3137
}

app/src/main/java/com/frogobox/research/exoplayer/WatchActivity.kt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.os.Bundle
66
import android.util.Log
77
import android.view.View
88
import android.widget.ImageView
9+
import android.widget.TextView
910
import androidx.activity.viewModels
1011
import androidx.appcompat.app.AppCompatActivity
1112
import androidx.core.view.WindowCompat
@@ -34,24 +35,42 @@ class WatchActivity : AppCompatActivity() {
3435
ActivityWatchBinding.inflate(layoutInflater)
3536
}
3637

38+
private val videoTitle: String by lazy(LazyThreadSafetyMode.NONE) {
39+
intent.getStringExtra(Constant.Extra.EXTRA_VIDEO_TITLE) ?: ""
40+
}
41+
42+
private val videoUrl: String by lazy(LazyThreadSafetyMode.NONE) {
43+
intent.getStringExtra(Constant.Extra.EXTRA_VIDEO_URL) ?: ""
44+
}
45+
3746
private val playbackStateListener: Player.Listener = playbackStateListener()
3847
private var player: ExoPlayer? = null
3948

4049
override fun onCreate(savedInstanceState: Bundle?) {
4150
super.onCreate(savedInstanceState)
4251
setContentView(binding.root)
52+
53+
val btnCloseVideo = binding.videoView.findViewById<ImageView>(R.id.iv_close_video)
54+
val tvTitleVideo = binding.videoView.findViewById<TextView>(R.id.tv_title_video)
4355
val fullscreenButton = binding.videoView.findViewById<ImageView>(R.id.exo_fullscreen_icon)
56+
57+
tvTitleVideo.text = videoTitle
58+
59+
btnCloseVideo.setOnClickListener {
60+
finish()
61+
}
62+
4463
fullscreenButton.setOnClickListener {
4564
if (isFullScreen) {
4665
supportActionBar?.show()
4766
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
4867
isFullScreen = false
49-
fullscreenButton.setImageResource(R.drawable.ic_baseline_fullscreen)
68+
fullscreenButton.setImageResource(R.drawable.ic_fullscreen)
5069
} else {
5170
supportActionBar?.hide()
5271
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
5372
isFullScreen = true
54-
fullscreenButton.setImageResource(R.drawable.ic_baseline_fullscreen_exit)
73+
fullscreenButton.setImageResource(R.drawable.ic_fullscreen_exit)
5574
}
5675
}
5776
}
@@ -81,7 +100,7 @@ class WatchActivity : AppCompatActivity() {
81100
exoPlayer.addAnalyticsListener(object : AnalyticsListener {
82101
override fun onPlaybackStateChanged(
83102
eventTime: AnalyticsListener.EventTime,
84-
state: Int
103+
state: Int,
85104
) {
86105
super.onPlaybackStateChanged(eventTime, state)
87106
Log.d(TAG, "onPlaybackStateChanged: $state")
@@ -138,7 +157,7 @@ class WatchActivity : AppCompatActivity() {
138157
// exoPlayer.setMediaYoutubeDashExt(getString(R.string.media_url_dash))
139158

140159
// Setup Handling Media Video
141-
exoPlayer.setSingleMediaExt(this, getString(R.string.media_url_youtube_link_1))
160+
exoPlayer.setSingleMediaExt(this, videoUrl)
142161

143162
// Default setup
144163
setupExoPlayerByViewModel(exoPlayer, playbackStateListener)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.frogobox.research.util
2+
3+
/**
4+
* Created by Faisal Amir on 20/10/22
5+
* -----------------------------------------
6+
* E-mail : [email protected]
7+
* Github : github.com/amirisback
8+
* -----------------------------------------
9+
* Copyright (C) Frogobox ID / amirisback
10+
* All rights reserved
11+
*/
12+
13+
object Constant {
14+
15+
object Extra {
16+
17+
const val EXTRA_VIDEO_URL = "extra_video"
18+
const val EXTRA_VIDEO_TITLE = "extra_video_title"
19+
20+
}
21+
22+
}

app/src/main/res/drawable/ic_baseline_forward.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

app/src/main/res/drawable/ic_baseline_pause.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/src/main/res/drawable/ic_baseline_play_arrow.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/src/main/res/drawable/ic_baseline_replay.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#FFFFFF"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
5+
</vector>

0 commit comments

Comments
 (0)