mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Fixed build error due to gitVersionName being null. Fixed jmDNS crash when stop was called before start. Added check that makes volume slider only perform calls when change volume is implemented. Fixed crash in onProgress whenever the HTTP request fails.
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ plugins {
|
||||
|
||||
ext {
|
||||
gitVersionName = grgit.describe()
|
||||
gitVersionCode = gitVersionName.isInteger() ? gitVersionName.toInteger() : 1
|
||||
gitVersionCode = gitVersionName != null && gitVersionName.isInteger() ? gitVersionName.toInteger() : 1
|
||||
}
|
||||
|
||||
println("Version Name: $gitVersionName")
|
||||
|
||||
@@ -29,7 +29,7 @@ import javax.jmdns.ServiceTypeListener
|
||||
class StateCasting {
|
||||
private val _scopeIO = CoroutineScope(Dispatchers.IO);
|
||||
private val _scopeMain = CoroutineScope(Dispatchers.Main);
|
||||
private lateinit var _jmDNS: JmDNS;
|
||||
private var _jmDNS: JmDNS? = null;
|
||||
private val _storage: CastingDeviceInfoStorage = FragmentedStorage.get();
|
||||
|
||||
private val _castServer = ManagedHttpServer(9999);
|
||||
@@ -162,14 +162,16 @@ class StateCasting {
|
||||
|
||||
_scopeIO.launch {
|
||||
try {
|
||||
_jmDNS = JmDNS.create(InetAddress.getLocalHost());
|
||||
_jmDNS.addServiceListener("_googlecast._tcp.local.", _chromecastServiceListener);
|
||||
_jmDNS.addServiceListener("_airplay._tcp.local.", _airPlayServiceListener);
|
||||
_jmDNS.addServiceListener("_fastcast._tcp.local.", _fastCastServiceListener);
|
||||
val jmDNS = JmDNS.create(InetAddress.getLocalHost());
|
||||
jmDNS.addServiceListener("_googlecast._tcp.local.", _chromecastServiceListener);
|
||||
jmDNS.addServiceListener("_airplay._tcp.local.", _airPlayServiceListener);
|
||||
jmDNS.addServiceListener("_fastcast._tcp.local.", _fastCastServiceListener);
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
_jmDNS.addServiceTypeListener(_serviceTypeListener);
|
||||
jmDNS.addServiceTypeListener(_serviceTypeListener);
|
||||
}
|
||||
|
||||
_jmDNS = jmDNS;
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to start casting service.", e);
|
||||
}
|
||||
@@ -189,20 +191,23 @@ class StateCasting {
|
||||
|
||||
Logger.i(TAG, "CastingService stopping.")
|
||||
|
||||
val jmDNS = _jmDNS;
|
||||
if (jmDNS != null) {
|
||||
_scopeIO.launch {
|
||||
try {
|
||||
_jmDNS.removeServiceListener("_googlecast._tcp.local.", _chromecastServiceListener);
|
||||
_jmDNS.removeServiceListener("_airplay._tcp", _airPlayServiceListener);
|
||||
jmDNS.removeServiceListener("_googlecast._tcp.local.", _chromecastServiceListener);
|
||||
jmDNS.removeServiceListener("_airplay._tcp", _airPlayServiceListener);
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
_jmDNS.removeServiceTypeListener(_serviceTypeListener);
|
||||
jmDNS.removeServiceTypeListener(_serviceTypeListener);
|
||||
}
|
||||
|
||||
_jmDNS.close();
|
||||
jmDNS.close();
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to stop mDNS.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_scopeIO.cancel();
|
||||
_scopeMain.cancel();
|
||||
|
||||
@@ -53,7 +53,17 @@ class ConnectedCastingDialog(context: Context?) : AlertDialog(context) {
|
||||
dismiss();
|
||||
};
|
||||
|
||||
_sliderVolume.addOnChangeListener(OnChangeListener { _, value, _ -> StateCasting.instance.activeDevice?.changeVolume(value.toDouble()); });
|
||||
//TODO: Check if volume slider is properly hidden in all cases
|
||||
_sliderVolume.addOnChangeListener(OnChangeListener { _, value, _ ->
|
||||
val activeDevice = StateCasting.instance.activeDevice ?: return@OnChangeListener;
|
||||
if (activeDevice.canSetVolume) {
|
||||
try {
|
||||
activeDevice.changeVolume(value.toDouble());
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to change volume.", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setLoading(false);
|
||||
updateDevice();
|
||||
|
||||
+4
@@ -1869,7 +1869,11 @@ class VideoDetailView : ConstraintLayout {
|
||||
}
|
||||
|
||||
fragment.lifecycleScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
playbackTracker.onProgress(positionMs.toDouble() / 1000, isPlaying);
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to notify progress.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user