Merge nowplaying-visualizer-coupling into dev (NowPlaying visualizer couples to live track when streaming starts)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
@using DeepDrftPublic.Client.Services
|
||||
@implements IDisposable
|
||||
|
||||
@* Hero-right panel (owns the navy backdrop + clipping, formerly Home.razor's .hero-right wrapper). *@
|
||||
<div class="now-playing-panel">
|
||||
@@ -39,4 +40,29 @@
|
||||
|
||||
@code {
|
||||
[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