mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-26 22:20:24 +00:00
fix differences between free and non free cast services
This commit is contained in:
parent
59a9538559
commit
1f14416b3d
5 changed files with 37 additions and 16 deletions
|
@ -6,30 +6,31 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
|
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
|
||||||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
|
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
|
||||||
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.StreamUrl
|
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.StreamUrl
|
||||||
|
import de.nicidienase.chaosflix.common.userdata.entities.progress.PlaybackProgress
|
||||||
import de.nicidienase.chaosflix.touch.browse.streaming.StreamingItem
|
import de.nicidienase.chaosflix.touch.browse.streaming.StreamingItem
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
class CastService {
|
class CastServiceImpl : CastService {
|
||||||
|
|
||||||
val connected: Boolean = false
|
override val connected: Boolean = false
|
||||||
|
|
||||||
fun castStream(streamingItem: StreamingItem, streamUrl: StreamUrl, contentKey: String) {
|
override fun castStream(streamingItem: StreamingItem, streamUrl: StreamUrl, contentKey: String) {
|
||||||
Log.e(TAG, "No Cast Support")
|
Log.e(TAG, "No Cast Support")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadMediaAndPlay(recording: Recording, event: Event) {
|
override fun loadMediaAndPlay(recording: Recording, event: Event, progress: PlaybackProgress?) {
|
||||||
Log.e(TAG, "No Cast Support")
|
Log.e(TAG, "No Cast Support")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addMediaRouteMenuItem(menu: Menu) {
|
override fun addMediaRouteMenuItem(menu: Menu) {
|
||||||
Log.i(TAG, "No Cast Support, adding no Menu item")
|
Log.i(TAG, "No Cast Support, adding no Menu item")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun attachToActivity(activity: AppCompatActivity) {
|
override fun attachToActivity(activity: AppCompatActivity) {
|
||||||
Log.i(TAG, "No Cast Support, doing nothing")
|
Log.i(TAG, "No Cast Support, doing nothing")
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val TAG = CastService::class.java.simpleName
|
private val TAG = CastServiceImpl::class.java.simpleName + "Free"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,6 +16,7 @@ import de.nicidienase.chaosflix.common.mediadata.StreamingRepository
|
||||||
import de.nicidienase.chaosflix.common.mediadata.ThumbnailParser
|
import de.nicidienase.chaosflix.common.mediadata.ThumbnailParser
|
||||||
import de.nicidienase.chaosflix.common.mediadata.network.ApiFactory
|
import de.nicidienase.chaosflix.common.mediadata.network.ApiFactory
|
||||||
import de.nicidienase.chaosflix.touch.browse.cast.CastService
|
import de.nicidienase.chaosflix.touch.browse.cast.CastService
|
||||||
|
import de.nicidienase.chaosflix.touch.browse.cast.CastServiceImpl
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
|
@ -40,7 +41,7 @@ class ViewModelFactory private constructor(context: Context) : ViewModelProvider
|
||||||
private val externalFilesDir = Environment.getExternalStorageDirectory()
|
private val externalFilesDir = Environment.getExternalStorageDirectory()
|
||||||
private val resourcesFacade by lazy { ResourcesFacade(context) }
|
private val resourcesFacade by lazy { ResourcesFacade(context) }
|
||||||
private val thumbnailParser by lazy { ThumbnailParser(apiFactory.client) }
|
private val thumbnailParser by lazy { ThumbnailParser(apiFactory.client) }
|
||||||
private val castService: CastService by lazy { CastService(database.playbackProgressDao(), coroutineScope) }
|
private val castService: CastService by lazy { CastServiceImpl(database.playbackProgressDao(), coroutineScope) }
|
||||||
val mediaRepository by lazy { MediaRepository(apiFactory.recordingApi, database) }
|
val mediaRepository by lazy { MediaRepository(apiFactory.recordingApi, database) }
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package de.nicidienase.chaosflix.touch.browse.cast
|
||||||
|
|
||||||
|
import android.view.Menu
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
|
||||||
|
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Recording
|
||||||
|
import de.nicidienase.chaosflix.common.mediadata.entities.streaming.StreamUrl
|
||||||
|
import de.nicidienase.chaosflix.common.userdata.entities.progress.PlaybackProgress
|
||||||
|
import de.nicidienase.chaosflix.touch.browse.streaming.StreamingItem
|
||||||
|
|
||||||
|
interface CastService {
|
||||||
|
val connected: Boolean
|
||||||
|
|
||||||
|
fun attachToActivity(activity: AppCompatActivity)
|
||||||
|
fun castStream(streamingItem: StreamingItem, streamUrl: StreamUrl, contentKey: String)
|
||||||
|
fun loadMediaAndPlay(recording: Recording, event: Event, progress: PlaybackProgress?)
|
||||||
|
fun addMediaRouteMenuItem(menu: Menu)
|
||||||
|
}
|
|
@ -24,18 +24,18 @@ import kotlinx.coroutines.launch
|
||||||
import pl.droidsonroids.casty.Casty
|
import pl.droidsonroids.casty.Casty
|
||||||
import pl.droidsonroids.casty.MediaData
|
import pl.droidsonroids.casty.MediaData
|
||||||
|
|
||||||
class CastService(
|
class CastServiceImpl(
|
||||||
private val playbackProgressDao: PlaybackProgressDao,
|
private val playbackProgressDao: PlaybackProgressDao,
|
||||||
private val scope: CoroutineScope
|
private val scope: CoroutineScope
|
||||||
) : LifecycleObserver {
|
) : LifecycleObserver, CastService {
|
||||||
|
|
||||||
private var currentEvent: Event? = null
|
private var currentEvent: Event? = null
|
||||||
|
|
||||||
private var casty: Casty? = null
|
private var casty: Casty? = null
|
||||||
val connected: Boolean
|
override val connected: Boolean
|
||||||
get() = casty?.isConnected ?: false
|
get() = casty?.isConnected ?: false
|
||||||
|
|
||||||
fun attachToActivity(activity: AppCompatActivity) {
|
override fun attachToActivity(activity: AppCompatActivity) {
|
||||||
casty = Casty.create(activity)
|
casty = Casty.create(activity)
|
||||||
activity.lifecycle.addObserver(this)
|
activity.lifecycle.addObserver(this)
|
||||||
currentEvent?.let {
|
currentEvent?.let {
|
||||||
|
@ -48,7 +48,7 @@ class CastService(
|
||||||
casty = null
|
casty = null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun castStream(streamingItem: StreamingItem, streamUrl: StreamUrl, contentKey: String) {
|
override fun castStream(streamingItem: StreamingItem, streamUrl: StreamUrl, contentKey: String) {
|
||||||
casty?.let {
|
casty?.let {
|
||||||
val contentType = getContentTypeForKey(contentKey)
|
val contentType = getContentTypeForKey(contentKey)
|
||||||
val mediaData = MediaData.Builder(streamUrl.url)
|
val mediaData = MediaData.Builder(streamUrl.url)
|
||||||
|
@ -62,7 +62,7 @@ class CastService(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadMediaAndPlay(recording: Recording, event: Event, progress: PlaybackProgress?) {
|
override fun loadMediaAndPlay(recording: Recording, event: Event, progress: PlaybackProgress?) {
|
||||||
Log.d(TAG, "Casting: ${event.title}")
|
Log.d(TAG, "Casting: ${event.title}")
|
||||||
currentEvent = event
|
currentEvent = event
|
||||||
casty?.let {
|
casty?.let {
|
||||||
|
@ -80,7 +80,7 @@ class CastService(
|
||||||
sessionManager?.currentCastSession?.let { sessionListener.attachProgressListener(it) }
|
sessionManager?.currentCastSession?.let { sessionListener.attachProgressListener(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addMediaRouteMenuItem(menu: Menu) {
|
override fun addMediaRouteMenuItem(menu: Menu) {
|
||||||
casty?.addMediaRouteMenuItem(menu)
|
casty?.addMediaRouteMenuItem(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +180,6 @@ class CastService(
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val TAG = CastService::class.java.simpleName
|
private val TAG = CastServiceImpl::class.java.simpleName + "NoFree"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
|
tools:replace="android:label"
|
||||||
tools:ignore="GoogleAppIndexingWarning">
|
tools:ignore="GoogleAppIndexingWarning">
|
||||||
<activity
|
<activity
|
||||||
android:name=".conferences.ConferencesActivity"
|
android:name=".conferences.ConferencesActivity"
|
||||||
|
|
Loading…
Reference in a new issue