fix: NowPlaying re-renders on StateChanged so WaveformVisualizer gets live track params when streaming starts
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
@using DeepDrftPublic.Client.Services
|
@using DeepDrftPublic.Client.Services
|
||||||
|
@implements IDisposable
|
||||||
|
|
||||||
@* Hero-right panel (owns the navy backdrop + clipping, formerly Home.razor's .hero-right wrapper). *@
|
@* Hero-right panel (owns the navy backdrop + clipping, formerly Home.razor's .hero-right wrapper). *@
|
||||||
<div class="now-playing-panel">
|
<div class="now-playing-panel">
|
||||||
@@ -39,4 +40,29 @@
|
|||||||
|
|
||||||
@code {
|
@code {
|
||||||
[CascadingParameter] public IStreamingPlayerService? Player { get; set; }
|
[CascadingParameter] public IStreamingPlayerService? Player { get; set; }
|
||||||
|
|
||||||
|
private IStreamingPlayerService? _subscribedPlayer;
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
if (Player != null && !ReferenceEquals(Player, _subscribedPlayer))
|
||||||
|
{
|
||||||
|
if (_subscribedPlayer != null)
|
||||||
|
_subscribedPlayer.StateChanged -= OnPlayerStateChanged;
|
||||||
|
|
||||||
|
Player.StateChanged += OnPlayerStateChanged;
|
||||||
|
_subscribedPlayer = Player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPlayerStateChanged() => InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (_subscribedPlayer != null)
|
||||||
|
{
|
||||||
|
_subscribedPlayer.StateChanged -= OnPlayerStateChanged;
|
||||||
|
_subscribedPlayer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user