Skip to content

Commit

Permalink
update: project
Browse files Browse the repository at this point in the history
  • Loading branch information
amirisback committed Oct 20, 2022
1 parent dd6a73b commit f1d0876
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 67 deletions.
25 changes: 13 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ plugins {
}

android {
compileSdk 32
compileSdk 33

defaultConfig {

applicationId "com.frogobox.research"
minSdk 21
targetSdk 32
targetSdk 33
versionCode 1
versionName "1.0"

Expand All @@ -36,32 +36,33 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
namespace 'com.frogobox.research'

}

dependencies {

implementation "androidx.core:core-ktx:1.8.0"
implementation "androidx.appcompat:appcompat:1.5.0"
implementation "androidx.core:core-ktx:1.9.0"
implementation "androidx.appcompat:appcompat:1.5.1"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.work:work-runtime-ktx:2.7.1"

implementation "androidx.activity:activity-ktx:1.5.1"
implementation "androidx.fragment:fragment-ktx:1.5.2"
implementation "androidx.activity:activity-ktx:1.6.0"
implementation "androidx.fragment:fragment-ktx:1.5.3"

implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-livedata-core-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1"

implementation "com.google.android.material:material:1.6.1"
implementation "com.google.android.material:material:1.7.0"

implementation "com.google.android.exoplayer:exoplayer:2.17.1"
implementation "com.google.android.exoplayer:exoplayer-core:2.17.1"
implementation "com.google.android.exoplayer:exoplayer-dash:2.17.1"
implementation "com.google.android.exoplayer:exoplayer-hls:2.17.1"
implementation "com.google.android.exoplayer:exoplayer-ui:2.17.1"
implementation "com.google.android.exoplayer:exoplayer:2.18.1"
implementation "com.google.android.exoplayer:exoplayer-core:2.18.1"
implementation "com.google.android.exoplayer:exoplayer-dash:2.18.1"
implementation "com.google.android.exoplayer:exoplayer-hls:2.18.1"
implementation "com.google.android.exoplayer:exoplayer-ui:2.18.1"

testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.frogobox.research">
xmlns:tools="http://schemas.android.com/tools">

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

Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/com/frogobox/research/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.frogobox.research.databinding.ActivityMainBinding
import com.frogobox.research.exoplayer.WatchActivity
import com.frogobox.research.util.Constant

class MainActivity : AppCompatActivity() {

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

private val binding: ActivityMainBinding by lazy {
Expand All @@ -25,7 +28,10 @@ class MainActivity : AppCompatActivity() {
private fun setupUI() {
binding.apply {
btnWatch.setOnClickListener {
startActivity(Intent(this@MainActivity, WatchActivity::class.java))
startActivity(Intent(this@MainActivity, WatchActivity::class.java).apply {
putExtra(Constant.Extra.EXTRA_VIDEO_URL, VIDEO_URL)
putExtra(Constant.Extra.EXTRA_VIDEO_TITLE, VIDEO_TITLE)
})
}
}
}
Expand Down
27 changes: 23 additions & 4 deletions app/src/main/java/com/frogobox/research/exoplayer/WatchActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.WindowCompat
Expand Down Expand Up @@ -34,24 +35,42 @@ class WatchActivity : AppCompatActivity() {
ActivityWatchBinding.inflate(layoutInflater)
}

private val videoTitle: String by lazy(LazyThreadSafetyMode.NONE) {
intent.getStringExtra(Constant.Extra.EXTRA_VIDEO_TITLE) ?: ""
}

private val videoUrl: String by lazy(LazyThreadSafetyMode.NONE) {
intent.getStringExtra(Constant.Extra.EXTRA_VIDEO_URL) ?: ""
}

private val playbackStateListener: Player.Listener = playbackStateListener()
private var player: ExoPlayer? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)

val btnCloseVideo = binding.videoView.findViewById<ImageView>(R.id.iv_close_video)
val tvTitleVideo = binding.videoView.findViewById<TextView>(R.id.tv_title_video)
val fullscreenButton = binding.videoView.findViewById<ImageView>(R.id.exo_fullscreen_icon)

tvTitleVideo.text = videoTitle

btnCloseVideo.setOnClickListener {
finish()
}

fullscreenButton.setOnClickListener {
if (isFullScreen) {
supportActionBar?.show()
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
isFullScreen = false
fullscreenButton.setImageResource(R.drawable.ic_baseline_fullscreen)
fullscreenButton.setImageResource(R.drawable.ic_fullscreen)
} else {
supportActionBar?.hide()
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
isFullScreen = true
fullscreenButton.setImageResource(R.drawable.ic_baseline_fullscreen_exit)
fullscreenButton.setImageResource(R.drawable.ic_fullscreen_exit)
}
}
}
Expand Down Expand Up @@ -81,7 +100,7 @@ class WatchActivity : AppCompatActivity() {
exoPlayer.addAnalyticsListener(object : AnalyticsListener {
override fun onPlaybackStateChanged(
eventTime: AnalyticsListener.EventTime,
state: Int
state: Int,
) {
super.onPlaybackStateChanged(eventTime, state)
Log.d(TAG, "onPlaybackStateChanged: $state")
Expand Down Expand Up @@ -138,7 +157,7 @@ class WatchActivity : AppCompatActivity() {
// exoPlayer.setMediaYoutubeDashExt(getString(R.string.media_url_dash))

// Setup Handling Media Video
exoPlayer.setSingleMediaExt(this, getString(R.string.media_url_youtube_link_1))
exoPlayer.setSingleMediaExt(this, videoUrl)

// Default setup
setupExoPlayerByViewModel(exoPlayer, playbackStateListener)
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/com/frogobox/research/util/Constant.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.frogobox.research.util

/**
* Created by Faisal Amir on 20/10/22
* -----------------------------------------
* E-mail : [email protected]
* Github : github.com/amirisback
* -----------------------------------------
* Copyright (C) Frogobox ID / amirisback
* All rights reserved
*/

object Constant {

object Extra {

const val EXTRA_VIDEO_URL = "extra_video"
const val EXTRA_VIDEO_TITLE = "extra_video_title"

}

}
7 changes: 0 additions & 7 deletions app/src/main/res/drawable/ic_baseline_forward.xml

This file was deleted.

5 changes: 0 additions & 5 deletions app/src/main/res/drawable/ic_baseline_pause.xml

This file was deleted.

5 changes: 0 additions & 5 deletions app/src/main/res/drawable/ic_baseline_play_arrow.xml

This file was deleted.

6 changes: 0 additions & 6 deletions app/src/main/res/drawable/ic_baseline_replay.xml

This file was deleted.

5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_close.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<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"/>
</vector>
File renamed without changes.
76 changes: 54 additions & 22 deletions app/src/main/res/layout/custom_controller.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
<?xml version="1.0" encoding="utf-8"?><!-- Copyright 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">

<!-- 0dp dimensions are used to prevent this view from influencing the size of
the parent view if it uses "wrap_content". It is expanded to occupy the
entirety of the parent in code, after the parent's size has been
determined. See: https://github.com/google/ExoPlayer/issues/8726.
-->
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:viewBindingIgnore="true">

<View
android:id="@id/exo_controls_background"
android:layout_width="0dp"
Expand Down Expand Up @@ -127,4 +112,51 @@

</LinearLayout>

</merge>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/tv_title_video"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:maxLines="2"
android:textColor="#000000"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="@id/iv_close_video"
app:layout_constraintEnd_toStartOf="@id/iv_close_video"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/iv_close_video"
tools:text="Grapic Design" />


<TextView
android:id="@+id/tv_copyright"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:maxLines="2"
android:textColor="#000000"
android:textSize="10sp"
android:text="This App Created By Faisal Amir"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_title_video"
android:layout_marginTop="16dp" />


<ImageView
android:id="@+id/iv_close_video"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_margin="16dp"
android:src="@drawable/ic_close"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

</merge>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id "com.android.application" version '7.2.2' apply false
id "com.android.library" version '7.2.2' apply false
id "com.android.application" version '7.3.1' apply false
id "com.android.library" version '7.3.1' apply false
id "org.jetbrains.kotlin.android" version "1.7.0" apply false
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Jun 12 12:51:08 WIB 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit f1d0876

Please sign in to comment.