Skip to content

Commit

Permalink
Source update
Browse files Browse the repository at this point in the history
  • Loading branch information
marcos4503 committed Oct 8, 2024
1 parent 6e5c5d8 commit b8cd87f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Source-Code/Motoplay.Desktop/Motoplay.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>motoplay-logo.ico</ApplicationIcon>
<AssemblyVersion>1.0.1</AssemblyVersion>
<AssemblyVersion>1.2.0</AssemblyVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion Source-Code/Motoplay/Motoplay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<LangVersion>latest</LangVersion>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<ApplicationIcon>Assets\motoplay-logo.ico</ApplicationIcon>
<AssemblyVersion>1.0.1</AssemblyVersion>
<AssemblyVersion>1.2.0</AssemblyVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
Expand Down
60 changes: 49 additions & 11 deletions Source-Code/Motoplay/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public enum LightShiftRotationState
Up,
Down
}
public enum VolumeButtonsState
{
Unknown,
Enabled,
Disabled
}

//Classes of script
private class BluetoothDeviceInScanLogs()
Expand Down Expand Up @@ -3520,15 +3526,9 @@ private void InitializeTheMusicPlayer()

//Show or hide the volume buttons control
if (appPrefs.loadedData.automaticVolume == true)
{
musicPlayer_volumeUpButton.IsEnabled = false;
musicPlayer_volumeDownButton.IsEnabled = false;
}
SetVolumeButtonsEnabled(false);
if (appPrefs.loadedData.automaticVolume == false)
{
musicPlayer_volumeUpButton.IsEnabled = true;
musicPlayer_volumeDownButton.IsEnabled = true;
}
SetVolumeButtonsEnabled(true);

//If don't have musics
if (musicPlayerFileList.Count == 0)
Expand Down Expand Up @@ -4184,19 +4184,40 @@ private void RenderAllMusicsOfDrives()
musicPlayer_drivesEmpty.IsVisible = false;
}

private void SetVolumeButtonsEnabled(bool enable)
{
//If is desired to enable
if (enable == true)
{
musicPlayer_volumeUpButton.IsEnabled = true;
musicPlayer_volumeDownButton.IsEnabled = true;
}

//If is desired to disable
if (enable == false)
{
musicPlayer_volumeUpButton.IsEnabled = false;
musicPlayer_volumeDownButton.IsEnabled = false;
}
}

private IEnumerator<Wait> MusicPlayerVehicleMoveMonitor()
{
//Wait a initial time, before start the move monitor
yield return new Wait(5.0f);

//Prepare the interval time
Wait intervalTime = new Wait(1.5f);

//Data variables
bool wasPausedByMonitor = false;
int currentAutoVolumeDefined = -1;
VolumeButtonsState currentVolumeBtState = VolumeButtonsState.Unknown;

//Start the monitor loop
while (true)
{
//If the auto pause is enabled
//If the auto pause is enabled, and have a active connection
if (appPrefs.loadedData.autoPauseOnStopVehicle == true && activeObdConnection != null)
{
if (activeObdConnection.transmissionGear == 0 && musicPlayerHandler.isPlaying() == true)
Expand All @@ -4206,7 +4227,7 @@ private IEnumerator<Wait> MusicPlayerVehicleMoveMonitor()
}
}

//If the auto pause is enabled
//If the auto pause is enabled, and have a active connection
if (appPrefs.loadedData.autoPlayOnVehicleMove == true && activeObdConnection != null)
{
if (activeObdConnection.transmissionGear > 0 && musicPlayerHandler.isPlaying() == false && wasPausedByMonitor == true)
Expand All @@ -4216,7 +4237,7 @@ private IEnumerator<Wait> MusicPlayerVehicleMoveMonitor()
}
}

//If the automatic volume is enabled
//If the automatic volume is enabled, and have a active connection
if (appPrefs.loadedData.automaticVolume == true && activeObdConnection != null)
{
//Prepare the target volume
Expand Down Expand Up @@ -4278,6 +4299,23 @@ private IEnumerator<Wait> MusicPlayerVehicleMoveMonitor()
//Inform the new current volume
currentAutoVolumeDefined = targetVolume;
}

//Disable the volume buttons, if needed
if (currentVolumeBtState != VolumeButtonsState.Disabled)
{
SetVolumeButtonsEnabled(false);
currentVolumeBtState = VolumeButtonsState.Disabled;
}
}
//If the automatic volume is enabled, and NOT have a active connection
if (appPrefs.loadedData.automaticVolume == true && activeObdConnection == null)
{
//Enable the volume buttons, if needed
if (currentVolumeBtState != VolumeButtonsState.Enabled)
{
SetVolumeButtonsEnabled(true);
currentVolumeBtState = VolumeButtonsState.Enabled;
}
}

//Wait time
Expand Down

0 comments on commit b8cd87f

Please sign in to comment.