Skip to content

Commit d625edd

Browse files
committed
[ISSUE-68] Removing unnecessary components
1 parent 5befc30 commit d625edd

File tree

5 files changed

+3
-183
lines changed

5 files changed

+3
-183
lines changed

core-shared-ui/src/main/java/com/codandotv/streamplayerapp/core_shared_ui/widget/PlayerComponent.kt

Lines changed: 3 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,27 @@
11
package com.codandotv.streamplayerapp.core_shared_ui.widget
22

3-
import androidx.compose.foundation.background
43
import androidx.compose.foundation.layout.Box
54
import androidx.compose.foundation.layout.Column
6-
import androidx.compose.foundation.layout.Row
5+
import androidx.compose.foundation.layout.fillMaxSize
76
import androidx.compose.foundation.layout.fillMaxWidth
87
import androidx.compose.foundation.layout.height
9-
import androidx.compose.foundation.layout.padding
10-
import androidx.compose.material3.MaterialTheme
118
import androidx.compose.runtime.Composable
129
import androidx.compose.runtime.DisposableEffect
13-
import androidx.compose.runtime.LaunchedEffect
14-
import androidx.compose.runtime.derivedStateOf
15-
import androidx.compose.runtime.getValue
16-
import androidx.compose.runtime.mutableStateOf
1710
import androidx.compose.runtime.remember
18-
import androidx.compose.runtime.setValue
1911
import androidx.compose.ui.Alignment
2012
import androidx.compose.ui.Modifier
2113
import androidx.compose.ui.platform.LocalContext
2214
import androidx.compose.ui.unit.dp
2315
import androidx.compose.ui.viewinterop.AndroidView
2416
import androidx.media3.common.MediaItem
25-
import androidx.media3.common.Player
2617
import androidx.media3.exoplayer.ExoPlayer
2718
import androidx.media3.ui.PlayerView
2819
import com.codandotv.streamplayerapp.core_shared_ui.theme.ThemePreviews
29-
import com.codandotv.streamplayerapp.core_shared_ui.widget.player.PlayerTracker
30-
import com.codandotv.streamplayerapp.core_shared_ui.widget.player.PreviewBadge
31-
import kotlinx.coroutines.delay
3220

3321
@Composable
3422
fun PlayerComponent(url: String, modifier: Modifier = Modifier) {
3523
val context = LocalContext.current
3624

37-
var isPlayerPlaying by remember { mutableStateOf(true) }
38-
39-
var playerPosition by remember { mutableStateOf(0L) }
40-
4125
val exoplayer = remember {
4226
val mediaItem = MediaItem.Builder()
4327
.setUri(url)
@@ -48,25 +32,12 @@ fun PlayerComponent(url: String, modifier: Modifier = Modifier) {
4832
prepare()
4933

5034
playWhenReady = true
51-
52-
addListener(
53-
object : Player.Listener {
54-
override fun onIsPlayingChanged(isPlaying: Boolean) {
55-
isPlayerPlaying = isPlaying
56-
}
57-
}
58-
)
5935
}
6036
}
6137

62-
val playerProgress by remember {
63-
derivedStateOf { (playerPosition / exoplayer.contentDuration.toDouble()).toFloat() }
64-
}
65-
6638
Column(
6739
modifier = modifier
68-
.height(225.dp)
69-
.fillMaxWidth()
40+
.fillMaxSize()
7041
) {
7142
Box {
7243
AndroidView(
@@ -77,49 +48,13 @@ fun PlayerComponent(url: String, modifier: Modifier = Modifier) {
7748
factory = {
7849
PlayerView(it).apply {
7950
player = exoplayer
80-
useController = false
51+
useController = true
8152
}
8253
}
8354
)
84-
85-
PreviewBadge(
86-
modifier = Modifier
87-
.align(Alignment.BottomStart)
88-
.padding(
89-
start = 8.dp,
90-
bottom = 8.dp
91-
)
92-
)
93-
}
94-
95-
Row(
96-
modifier = Modifier
97-
.fillMaxWidth()
98-
.height(25.dp)
99-
.background(MaterialTheme.colorScheme.background)
100-
) {
101-
PlayerTracker(
102-
modifier = Modifier
103-
.fillMaxWidth()
104-
.height(18.dp)
105-
.padding(horizontal = 0.dp),
106-
percentage = playerProgress,
107-
expanded = false
108-
)
10955
}
11056
}
11157

112-
113-
LaunchedEffect(
114-
key1 = isPlayerPlaying,
115-
block = {
116-
while (isPlayerPlaying) {
117-
delay(500L)
118-
playerPosition += 500L
119-
}
120-
}
121-
)
122-
12358
DisposableEffect(key1 = Unit, effect = {
12459
onDispose {
12560
exoplayer.release()

core-shared-ui/src/main/java/com/codandotv/streamplayerapp/core_shared_ui/widget/player/PlayerTracker.kt

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

core-shared-ui/src/main/java/com/codandotv/streamplayerapp/core_shared_ui/widget/player/PreviewBadge.kt

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

feature-list-streams/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@ dependencies {
1717
implementation(libs.coil)
1818

1919
testImplementation(libs.bundles.test)
20-
21-
implementation(libs.android.youtubeExtractor)
2220
}

gradle/libs.versions.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[versions]
2-
androidYoutubeextractor = "v2.1.0"
32
kotlin = "1.8.10"
43
android_gradle_plugin = "7.4.2"
54
koin = "3.4.0"
@@ -46,7 +45,6 @@ lottie = "5.2.0"
4645
media3 = "1.1.0"
4746

4847
[libraries]
49-
android-youtubeExtractor = { module = "com.github.HaarigerHarald:android-youtubeExtractor", version.ref = "androidYoutubeextractor" }
5048
kotlin_gradle_plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
5149
android_gradle_plugin = { group = "com.android.tools.build", name = "gradle", version.ref = "android_gradle_plugin" }
5250

0 commit comments

Comments
 (0)