Skip to content

Commit f1d0876

Browse files
committed
update: project
1 parent dd6a73b commit f1d0876

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>

app/src/main/res/layout/custom_controller.xml

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
1-
<?xml version="1.0" encoding="utf-8"?><!-- Copyright 2020 The Android Open Source Project
2-
3-
Licensed under the Apache License, Version 2.0 (the "License");
4-
you may not use this file except in compliance with the License.
5-
You may obtain a copy of the License at
6-
7-
http://www.apache.org/licenses/LICENSE-2.0
8-
9-
Unless required by applicable law or agreed to in writing, software
10-
distributed under the License is distributed on an "AS IS" BASIS,
11-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
See the License for the specific language governing permissions and
13-
limitations under the License.
14-
-->
15-
<merge xmlns:android="http://schemas.android.com/apk/res/android">
16-
17-
<!-- 0dp dimensions are used to prevent this view from influencing the size of
18-
the parent view if it uses "wrap_content". It is expanded to occupy the
19-
entirety of the parent in code, after the parent's size has been
20-
determined. See: https://github.com/google/ExoPlayer/issues/8726.
21-
-->
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<merge xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
tools:viewBindingIgnore="true">
6+
227
<View
238
android:id="@id/exo_controls_background"
249
android:layout_width="0dp"
@@ -127,4 +112,51 @@
127112

128113
</LinearLayout>
129114

130-
</merge>
115+
<androidx.constraintlayout.widget.ConstraintLayout
116+
android:layout_width="match_parent"
117+
android:layout_height="wrap_content">
118+
119+
<TextView
120+
android:id="@+id/tv_title_video"
121+
android:layout_width="0dp"
122+
android:layout_height="wrap_content"
123+
android:layout_marginStart="16dp"
124+
android:layout_marginEnd="16dp"
125+
android:maxLines="2"
126+
android:textColor="#000000"
127+
android:textSize="16sp"
128+
app:layout_constraintBottom_toBottomOf="@id/iv_close_video"
129+
app:layout_constraintEnd_toStartOf="@id/iv_close_video"
130+
app:layout_constraintStart_toStartOf="parent"
131+
app:layout_constraintTop_toTopOf="@id/iv_close_video"
132+
tools:text="Grapic Design" />
133+
134+
135+
<TextView
136+
android:id="@+id/tv_copyright"
137+
android:layout_width="0dp"
138+
android:layout_height="wrap_content"
139+
android:layout_marginStart="16dp"
140+
android:layout_marginEnd="16dp"
141+
android:maxLines="2"
142+
android:textColor="#000000"
143+
android:textSize="10sp"
144+
android:text="This App Created By Faisal Amir"
145+
app:layout_constraintStart_toStartOf="parent"
146+
app:layout_constraintTop_toBottomOf="@id/tv_title_video"
147+
android:layout_marginTop="16dp" />
148+
149+
150+
<ImageView
151+
android:id="@+id/iv_close_video"
152+
android:layout_width="24dp"
153+
android:layout_height="24dp"
154+
android:layout_margin="16dp"
155+
android:src="@drawable/ic_close"
156+
app:layout_constraintBottom_toBottomOf="parent"
157+
app:layout_constraintEnd_toEndOf="parent"
158+
app:layout_constraintTop_toTopOf="parent" />
159+
160+
</androidx.constraintlayout.widget.ConstraintLayout>
161+
162+
</merge>

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
plugins {
3-
id "com.android.application" version '7.2.2' apply false
4-
id "com.android.library" version '7.2.2' apply false
3+
id "com.android.application" version '7.3.1' apply false
4+
id "com.android.library" version '7.3.1' apply false
55
id "org.jetbrains.kotlin.android" version "1.7.0" apply false
66
}
77

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Sun Jun 12 12:51:08 WIB 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)