Skip to content

Commit d181a06

Browse files
committed
V1.3.0 Release
1 parent 78d50c7 commit d181a06

10 files changed

Lines changed: 130 additions & 84 deletions

AVRControl.Designer.cs

Lines changed: 31 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AVRControl.Helpers.cs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,46 +26,52 @@ public partial class AVRControl : Form
2626
{
2727
private void timerProgress_Tick(object sender, EventArgs e)
2828
{
29-
if (!IsAVROn)
30-
{
31-
timerProgress.Stop();
32-
return;
33-
}
29+
if (!IsAVROn) { timerProgress.Stop(); return; }
3430

3531
if (_maxDuration > 0)
3632
{
37-
_localCurPos += timerProgress.Interval; // 100ms oder 1000ms
33+
_localCurPos += timerProgress.Interval;
3834

3935
if (_localCurPos <= _maxDuration)
4036
{
41-
pbProgress.Value = Math.Min(_localCurPos, _maxDuration);
37+
double percent = (double)_localCurPos / _maxDuration;
38+
pnlProgressBar.Width = (int)(pnlProgressBack.ClientRectangle.Width * Math.Min(percent, 1.0));
39+
4240
lblTime.Text = $"{FormatTime(_localCurPos)} / {FormatTime(_maxDuration)}";
4341
}
4442
}
4543
}
44+
4645
private void StopHeosTimeline()
4746
{
4847
// _isMusicPlaying = false;
4948
_maxDuration = 0;
5049
_localCurPos = 0;
5150

52-
this.Invoke((MethodInvoker)delegate {
53-
timerProgress.Stop();
54-
pbProgress.Value = 0;
55-
lblTime.Text = "00:00 / 00:00";
56-
});
51+
if (this.InvokeRequired)
52+
{
53+
this.Invoke((MethodInvoker)delegate {
54+
timerProgress.Stop();
55+
pnlProgressBar.Width = 0;
56+
lblTime.Text = "00:00 / 00:00";
57+
});
58+
}
5759
}
5860

5961
private void ResetTimelineImmediate()
6062
{
6163
_localCurPos = 0;
6264
_lastUserInteraction = DateTime.Now;
6365

64-
this.Invoke((MethodInvoker)delegate {
65-
pbProgress.Value = 0;
66-
lblTime.Text = "00:00 / 00:00";
67-
});
66+
if (this.IsHandleCreated)
67+
{
68+
this.Invoke((MethodInvoker)delegate {
69+
pnlProgressBar.Width = 0;
70+
lblTime.Text = "00:00 / 00:00";
71+
});
72+
}
6873
}
74+
6975
private string ExtractJsonValue(string data, string key)
7076
{
7177
if (string.IsNullOrEmpty(data) || string.IsNullOrEmpty(key)) return "";

AVRControl.HeosUI.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ private void ParseAndDisplayTrackInfo(string json)
113113
if (_maxDuration != duration)
114114
{
115115
_maxDuration = duration;
116-
117-
pbProgress.Value = 0;
118-
pbProgress.Maximum = _maxDuration;
119-
116+
pnlProgressBar.Width = 0;
120117
_localCurPos = curPos;
121118
}
122119

@@ -125,7 +122,10 @@ private void ParseAndDisplayTrackInfo(string json)
125122
_localCurPos = curPos;
126123
}
127124

128-
pbProgress.Value = Math.Min(_localCurPos, pbProgress.Maximum);
125+
double percent = (double)_localCurPos / _maxDuration;
126+
pnlProgressBar.Width = (int)(pnlProgressBack.ClientRectangle.Width * Math.Min(percent, 1.0));
127+
128+
lblTime.Text = $"{FormatTime(_localCurPos)} / {FormatTime(_maxDuration)}";
129129

130130
if (state == "play" && IsAVROn)
131131
{
@@ -137,8 +137,9 @@ private void ParseAndDisplayTrackInfo(string json)
137137
}
138138
}
139139

140-
//Console.WriteLine($"Anzeige aktualisiert: [{serviceName}] {state} - {artist} - {song}");
141140
});
141+
142+
142143
}
143144
catch (Exception ex)
144145
{
@@ -149,7 +150,6 @@ private async Task UpdateHeosDetails()
149150
{
150151
if (string.IsNullOrEmpty(_activePid))
151152
{
152-
// Console.WriteLine("PID ist LEER!");
153153
await _heosTelnet.SendAsync("heos://player/get_players");
154154
return;
155155
}

AVRControl.Parser.cs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private async void OnDataReceived(string data)
5858
return;
5959
}
6060

61-
Console.WriteLine($"NORMALDATA: {data}");
61+
// Console.WriteLine($"NORMALDATA: {data}");
6262

6363
if (data.StartsWith("MVMAX")) // We dont need it
6464
{
@@ -248,26 +248,43 @@ private void OnHeosDataReceived(string data)
248248
if (int.TryParse(ExtractJsonValue(data, "cur_pos"), out int curPos) &&
249249
int.TryParse(ExtractJsonValue(data, "duration"), out int duration))
250250
{
251+
252+
if (_songChangePending || (curPos < 1000 && _localCurPos > 5000))
253+
{
254+
_localCurPos = 0;
255+
_songChangePending = false;
256+
}
257+
258+
if (curPos == 0 && _localCurPos > 2000 && !_songChangePending) return;
259+
251260
_maxDuration = duration;
252261

253262
if ((DateTime.Now - _lastUserInteraction).TotalSeconds >= 3.0)
254263
{
255-
if (Math.Abs(_localCurPos - curPos) > 2000) _localCurPos = curPos;
264+
_localCurPos = curPos;
256265
}
257266

258-
if (pbProgress.Maximum != _maxDuration)
259-
pbProgress.Maximum = _maxDuration;
267+
double percent = (double)_localCurPos / _maxDuration;
268+
pnlProgressBar.Width = (int)(pnlProgressBack.ClientRectangle.Width * Math.Min(percent, 1.0));
260269
}
261270
return;
262271
}
263272

273+
264274
if (data.Contains("event/player_now_playing_changed"))
265275
{
276+
_songChangePending = true;
266277
_localCurPos = 0;
267-
pbProgress.Value = 0;
278+
_maxDuration = 0;
279+
pnlProgressBar.Width = 0;
280+
lblTime.Text = "00:00 / 00:00";
281+
268282
_ = UpdateHeosDetails();
283+
return;
269284
}
270285

286+
287+
271288
if (data.Contains("player/get_now_playing_media"))
272289
{
273290
if (data.Contains("success"))
@@ -276,7 +293,7 @@ private void OnHeosDataReceived(string data)
276293
}
277294
else
278295
{
279-
Console.WriteLine("HEOS meldete Fail - ignoriere Anzeige-Update.");
296+
//Console.WriteLine("HEOS meldete Fail - ignoriere Anzeige-Update.");
280297
}
281298
}
282299

AVRControl.Toggles.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ private void AVRControlsToggle(bool enabled)
2828
return;
2929
}
3030

31+
IsAVROn = enabled;
32+
3133
this.btnVolUp.Enabled = enabled;
3234
this.btnVolDown.Enabled = enabled;
3335
this.btnToggleMute.Enabled = enabled;
@@ -93,6 +95,8 @@ private void HeosControlsToggle(bool enabled)
9395
this.btnHeosPlayRepeatAll.Enabled = enabled;
9496
this.btnHeosPlayRepeatOne.Enabled = enabled;
9597

98+
this.pnlProgressBack.Visible = enabled;
99+
96100
if (!enabled || !IsAVROn)
97101
{
98102
this.pbAlbumArt.Hide();

0 commit comments

Comments
 (0)