Skip to content

Commit

Permalink
Merge pull request #84 from TheXtremeLabs/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
MichaelStH authored Jan 24, 2024
2 parents 88bb42b + cd54f96 commit 971ec8a
Show file tree
Hide file tree
Showing 21 changed files with 492 additions and 39 deletions.
7 changes: 3 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ plugins {
id("thelab.android.hilt")
id("jacoco")
id("thelab.firebase")
alias(libs.plugins.ksp)
}

android {
Expand Down Expand Up @@ -124,6 +125,7 @@ dependencies {
implementation(project(":feature:musicrecognition"))
implementation(project(":feature:schedule"))
implementation(project(":feature:settings"))
implementation(project(":feature:streaming"))
implementation(project(":feature:theaters"))
implementation(project(":feature:weather"))

Expand All @@ -141,6 +143,7 @@ dependencies {
implementation(libs.kotlinx.play.services)

// AndroidX
implementation(libs.androidx.startup)
implementation(libs.androidx.multidex)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.core.splashscreen)
Expand All @@ -158,10 +161,6 @@ dependencies {
// Compose: provided by ui module
// The others dependencies has been added into the AndroidCompose plugin convention class

// Navigation
/*implementation(libs.androidx.navigation.ktx)
implementation(libs.androidx.navigation.fragment)*/

// CameraX
implementation(libs.androidx.camera)
implementation(libs.androidx.camera.lifecycle)
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.any" />
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-feature android:name="android.hardware.camera.autofocus" />
<!--<uses-feature android:name="android.hardware.camera.external"/>
<uses-feature android:name="android.hardware.camera.flash"/>-->

Expand Down Expand Up @@ -504,6 +504,12 @@
android:parentActivityName=".feature.musicrecognition.ui.MusicRecognitionChooserActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />

<activity
android:name=".feature.streaming.StreamingActivity"
android:parentActivityName=".ui.mainactivity.MainActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<!-- ////////////// ACTIVITIES ////////////// -->


Expand Down
26 changes: 22 additions & 4 deletions app/src/main/java/com/riders/thelab/utils/AppBuilderUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import com.riders.thelab.core.data.local.model.app.App
import com.riders.thelab.core.data.local.model.app.AppBuilder
import com.riders.thelab.feature.biometric.ui.BiometricActivity
import com.riders.thelab.feature.bluetooth.BluetoothActivity
import com.riders.thelab.feature.colors.ColorActivity
import com.riders.thelab.feature.download.DownloadActivity
import com.riders.thelab.feature.kat.ui.KatSplashscreenActivity
import com.riders.thelab.feature.lottie.LottieActivity
import com.riders.thelab.feature.musicrecognition.ui.MusicRecognitionChooserActivity
import com.riders.thelab.feature.schedule.ui.ScheduleActivity
import com.riders.thelab.feature.streaming.StreamingActivity
import com.riders.thelab.feature.theaters.TheatersActivity
import com.riders.thelab.feature.weather.ui.WeatherActivity
import com.riders.thelab.ui.builtin.BuiltInWebViewActivity
import com.riders.thelab.ui.camera.CameraActivity
import com.riders.thelab.feature.colors.ColorActivity
import com.riders.thelab.feature.schedule.ui.ScheduleActivity
import com.riders.thelab.ui.compose.ComposeActivity
import com.riders.thelab.ui.contacts.ContactsActivity
import com.riders.thelab.ui.customtoast.CustomToastActivity
Expand All @@ -31,7 +33,6 @@ import com.riders.thelab.ui.screenshot.ScreenShotActivity
import com.riders.thelab.ui.songplayer.SongPlayerActivity
import com.riders.thelab.ui.spring.SpringActivity
import com.riders.thelab.ui.tabs.WorkingTabsActivity
import com.riders.thelab.feature.theaters.TheatersActivity
import com.riders.thelab.ui.transition.TransitionActivity
import com.riders.thelab.ui.vectordrawables.VectorDrawablesActivity
import com.riders.thelab.ui.youtubelike.YoutubeLikeActivity
Expand Down Expand Up @@ -202,7 +203,7 @@ object AppBuilderUtils {
)
)
.withActivityClass(TheatersActivity::class.java)
.withActivityDate("2024/01/14")
.withActivityDate("2024/01/24")
.build()
this.add(theaters)

Expand Down Expand Up @@ -521,6 +522,23 @@ object AppBuilderUtils {
.build()
this.add(liveBarcode)

// Streaming
val streaming =
AppBuilder
.withId(33)
.withActivityTitle(context.getString(com.riders.thelab.core.ui.R.string.activity_title_streaming))
.withActivityDescription("Use ExoPlayer to stream media from YouTube, Vimeo, Dailymotion, Twitch, and more...")
.withActivityIcon(
getDrawableFromIntResource(
context,
com.riders.thelab.core.ui.R.drawable.ic_streaming
)
)
.withActivityClass(StreamingActivity::class.java)
.withActivityDate("2024/01/24")
.build()
this.add(streaming)

// Wip
val wip =
AppBuilder
Expand Down
2 changes: 1 addition & 1 deletion build-logic/config/src/main/kotlin/AndroidConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object AndroidConfiguration {

object Application {
const val code: Int = 1
val version: Version = Version(major = 12, minor = 12, patch = 0)
val version: Version = Version(major = 12, minor = 13, patch = 1)
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id("thelab.android.room")
id("thelab.android.library.jacoco")
id("kotlin-parcelize")
id("kotlinx-serialization")
alias(libs.plugins.kotlin.serialization)
}

android {
Expand Down
5 changes: 5 additions & 0 deletions core/player/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ dependencies {
implementation(project(":core:ui"))

implementation(libs.androidx.media.common)
implementation(libs.androidx.media.cast)
implementation(libs.androidx.media.decoder)
implementation(libs.androidx.media.exoplayer)
implementation(libs.androidx.media.exoplayer.dash)
implementation(libs.androidx.media.exoplayer.hls)
implementation(libs.androidx.media.exoplayer.rtsp)
implementation(libs.androidx.media.ui)
implementation(libs.youtube.player)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.viewinterop.AndroidView
import androidx.media3.common.AudioAttributes
import androidx.media3.common.C
import androidx.media3.common.MediaItem
import androidx.media3.common.MimeTypes
import androidx.media3.common.PlaybackException
import androidx.media3.common.Player
import androidx.media3.common.util.UnstableApi
Expand All @@ -21,11 +23,27 @@ import androidx.media3.ui.PlayerView
import timber.log.Timber
import java.net.UnknownHostException


/**
* Create an ExoPlayer composable that plays media from a URL.
*
* @param url The URL of the media to be played.
* @param modifier A [Modifier] for the root of the player.
* @param isSourceM3u8 boolean value to specify is the content is streaming or not
*/
@SuppressLint("OpaqueUnitKey")
@OptIn(UnstableApi::class)
@Composable
fun ExoPlayer(modifier: Modifier = Modifier, url: String) {
fun ExoPlayer(
modifier: Modifier = Modifier,
url: String,
hasControls: Boolean = true,
repeatMode: Int = Player.REPEAT_MODE_OFF,
isSourceM3u8: Boolean = false,
onPlayerErrorExceptionCaught: (Exception) -> Unit
) {

Timber.d("ExoPlayer() | url: $url | isSourceM3u8: $isSourceM3u8")

val context = LocalContext.current
val scope = rememberCoroutineScope()
var handler: Handler? = Handler(Looper.getMainLooper())
Expand All @@ -35,16 +53,28 @@ fun ExoPlayer(modifier: Modifier = Modifier, url: String) {
.build()
.also { exoPlayer ->
// Build the media item.
val mediaItem = MediaItem.Builder()
.setUri(url)
.build()
val mediaItem = MediaItem.Builder().apply {
setUri(url)

if (isSourceM3u8) {
//m3u8 is the extension used with HLS sources
setMimeType(MimeTypes.APPLICATION_M3U8)
}
}.build()

// Set the media item to be played.
exoPlayer.setMediaItem(mediaItem)

exoPlayer.repeatMode = Player.REPEAT_MODE_OFF
exoPlayer.repeatMode = repeatMode
exoPlayer.videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING

//set up audio attributes
val audioAttributes = AudioAttributes.Builder()
.setUsage(C.USAGE_MEDIA)
.setContentType(C.AUDIO_CONTENT_TYPE_MOVIE)
.build()
exoPlayer.setAudioAttributes(audioAttributes, false)

// Add Listener
exoPlayer.addListener(object : Player.Listener {
override fun onPlaybackStateChanged(playbackState: Int) {
Expand Down Expand Up @@ -86,6 +116,7 @@ fun ExoPlayer(modifier: Modifier = Modifier, url: String) {
override fun onPlayerError(error: PlaybackException) {
val cause = error.cause
Timber.e("onPlayerError() | message: $cause")
onPlayerErrorExceptionCaught(error)

if (cause is HttpDataSource.HttpDataSourceException) {
// An HTTP error occurred.
Expand Down Expand Up @@ -115,8 +146,13 @@ fun ExoPlayer(modifier: Modifier = Modifier, url: String) {
PlayerView(factoryContext).apply {
// Bind the player to the view.
this.player = exoPlayer
this.controllerAutoShow = true
this.controllerHideOnTouch = true

//hiding all the ui StyledPlayerView comes with
this.setShowNextButton(hasControls)
this.setShowPreviousButton(hasControls)

this.controllerAutoShow = hasControls
this.controllerHideOnTouch = hasControls
}
}
) { playerView ->
Expand Down
Loading

0 comments on commit 971ec8a

Please sign in to comment.