mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00: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:
parent
5b815f9c16
commit
4437bd7d51
4 changed files with 38 additions and 19 deletions
|
@ -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,18 +191,21 @@ class StateCasting {
|
|||
|
||||
Logger.i(TAG, "CastingService stopping.")
|
||||
|
||||
_scopeIO.launch {
|
||||
try {
|
||||
_jmDNS.removeServiceListener("_googlecast._tcp.local.", _chromecastServiceListener);
|
||||
_jmDNS.removeServiceListener("_airplay._tcp", _airPlayServiceListener);
|
||||
val jmDNS = _jmDNS;
|
||||
if (jmDNS != null) {
|
||||
_scopeIO.launch {
|
||||
try {
|
||||
jmDNS.removeServiceListener("_googlecast._tcp.local.", _chromecastServiceListener);
|
||||
jmDNS.removeServiceListener("_airplay._tcp", _airPlayServiceListener);
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
_jmDNS.removeServiceTypeListener(_serviceTypeListener);
|
||||
if (BuildConfig.DEBUG) {
|
||||
jmDNS.removeServiceTypeListener(_serviceTypeListener);
|
||||
}
|
||||
|
||||
jmDNS.close();
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to stop mDNS.", e);
|
||||
}
|
||||
|
||||
_jmDNS.close();
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to stop mDNS.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1869,7 +1869,11 @@ class VideoDetailView : ConstraintLayout {
|
|||
}
|
||||
|
||||
fragment.lifecycleScope.launch(Dispatchers.IO) {
|
||||
playbackTracker.onProgress(positionMs.toDouble() / 1000, isPlaying);
|
||||
try {
|
||||
playbackTracker.onProgress(positionMs.toDouble() / 1000, isPlaying);
|
||||
} catch (e: Throwable) {
|
||||
Logger.e(TAG, "Failed to notify progress.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue