mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-05-29 04:50:19 +02:00
Added support for automatically resuming casting device if stopped.
This commit is contained in:
parent
627b8c2b5d
commit
d3ab8ecf3a
@ -5,6 +5,7 @@ import android.content.Context
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
|
import android.util.Log
|
||||||
import com.futo.platformplayer.BuildConfig
|
import com.futo.platformplayer.BuildConfig
|
||||||
import com.futo.platformplayer.UIDialogs
|
import com.futo.platformplayer.UIDialogs
|
||||||
import com.futo.platformplayer.api.http.ManagedHttpClient
|
import com.futo.platformplayer.api.http.ManagedHttpClient
|
||||||
@ -67,6 +68,7 @@ class StateCasting {
|
|||||||
val onActiveDeviceTimeChanged = Event1<Double>();
|
val onActiveDeviceTimeChanged = Event1<Double>();
|
||||||
var activeDevice: CastingDevice? = null;
|
var activeDevice: CastingDevice? = null;
|
||||||
private val _client = ManagedHttpClient();
|
private val _client = ManagedHttpClient();
|
||||||
|
var _resumeCastingDevice: CastingDeviceInfo? = null;
|
||||||
|
|
||||||
val isCasting: Boolean get() = activeDevice != null;
|
val isCasting: Boolean get() = activeDevice != null;
|
||||||
|
|
||||||
@ -194,16 +196,30 @@ class StateCasting {
|
|||||||
|
|
||||||
fun onStop() {
|
fun onStop() {
|
||||||
val ad = activeDevice ?: return;
|
val ad = activeDevice ?: return;
|
||||||
|
_resumeCastingDevice = ad.getDeviceInfo()
|
||||||
|
Log.i(TAG, "_resumeCastingDevice set to '${ad.name}'")
|
||||||
Logger.i(TAG, "Stopping active device because of onStop.");
|
Logger.i(TAG, "Stopping active device because of onStop.");
|
||||||
ad.stop();
|
ad.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onResume() {
|
||||||
|
val resumeCastingDevice = _resumeCastingDevice
|
||||||
|
if (resumeCastingDevice != null) {
|
||||||
|
connectDevice(deviceFromCastingDeviceInfo(resumeCastingDevice))
|
||||||
|
_resumeCastingDevice = null
|
||||||
|
Log.i(TAG, "_resumeCastingDevice set to null onResume")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun start(context: Context) {
|
fun start(context: Context) {
|
||||||
if (_started)
|
if (_started)
|
||||||
return;
|
return;
|
||||||
_started = true;
|
_started = true;
|
||||||
|
|
||||||
|
Log.i(TAG, "_resumeCastingDevice set null start")
|
||||||
|
_resumeCastingDevice = null;
|
||||||
|
|
||||||
Logger.i(TAG, "CastingService starting...");
|
Logger.i(TAG, "CastingService starting...");
|
||||||
|
|
||||||
rememberedDevices.clear();
|
rememberedDevices.clear();
|
||||||
|
@ -331,6 +331,8 @@ class VideoDetailFragment : MainFragment {
|
|||||||
Logger.i(TAG, "Real orientation on boot ${realOrientation}, lastOrientation: ${lastOrientation}");
|
Logger.i(TAG, "Real orientation on boot ${realOrientation}, lastOrientation: ${lastOrientation}");
|
||||||
if(realOrientation != lastOrientation)
|
if(realOrientation != lastOrientation)
|
||||||
onOrientationChanged(realOrientation);
|
onOrientationChanged(realOrientation);
|
||||||
|
|
||||||
|
StateCasting.instance.onResume();
|
||||||
}
|
}
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user