Cleanup & Bug Fixes
- WebAssembly fix (missing app.Run) - API comms cleanup
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
@page "/tracks"
|
||||
@page "/tracks"
|
||||
@rendermode @(new InteractiveAutoRenderMode(prerender: false))
|
||||
|
||||
@using DeepDrftWeb.Client.Controls
|
||||
|
||||
@@ -19,6 +20,16 @@
|
||||
SelectedChanged="@SetPage"
|
||||
BoundaryCount="2"
|
||||
MiddleCount="3"/>
|
||||
|
||||
<div class="interactivity-test mt-4">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="TestInteractivity">
|
||||
Test Interactivity (@_clickCount)
|
||||
</MudButton>
|
||||
<MudText Typo="Typo.body2" Class="mt-2">
|
||||
Lifecycle Status: @_lifecycleStatus
|
||||
</MudText>
|
||||
</div>
|
||||
|
||||
<AudioPlayerBar AudioPlaybackEngine="AudioPlaybackEngine" />
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using DeepDrftModels.Entities;
|
||||
using DeepDrftModels.Entities;
|
||||
using DeepDrftModels.Models;
|
||||
using DeepDrftWeb.Client.Services;
|
||||
using DeepDrftWeb.Client.ViewModels;
|
||||
@@ -12,13 +12,29 @@ public partial class TracksView : ComponentBase
|
||||
[Inject] public required AudioPlaybackEngine AudioPlaybackEngine { get; set; }
|
||||
|
||||
private TrackEntity? _selectedTrack = null;
|
||||
private int _clickCount = 0;
|
||||
private string _lifecycleStatus = "Not initialized";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_lifecycleStatus = "OnInitializedAsync called";
|
||||
await SetPage(1);
|
||||
|
||||
if (!RendererInfo.IsInteractive) return;
|
||||
await AudioPlaybackEngine.InitializeAudioPlayer();
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
_lifecycleStatus = "OnAfterRenderAsync called - WebAssembly is active!";
|
||||
await AudioPlaybackEngine.InitializeAudioPlayer();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void TestInteractivity()
|
||||
{
|
||||
_clickCount++;
|
||||
_lifecycleStatus = $"Button clicked {_clickCount} times - Interactivity working!";
|
||||
}
|
||||
|
||||
private async Task SetPage(int newPage)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using DeepDrftWeb.Client;
|
||||
using DeepDrftWeb.Client.Services;
|
||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||
using MudBlazor.Services;
|
||||
|
||||
@@ -16,3 +15,5 @@ Startup.ConfigureContentServices(builder.Services, contentApiUrl);
|
||||
Startup.ConfigureDomainServices(builder.Services);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
await app.RunAsync();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<Router AppAssembly="typeof(Program).Assembly">
|
||||
<Router AppAssembly="typeof(_Imports).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
|
||||
<FocusOnNavigate RouteData="routeData" Selector="h1" />
|
||||
</Found>
|
||||
</Router>
|
||||
|
||||
@@ -13,6 +13,7 @@ public class AudioPlaybackEngine : IAsyncDisposable
|
||||
public required AudioInteropService AudioInterop { get; set; }
|
||||
|
||||
public string PlayerId { get; private set; } = Guid.NewGuid().ToString();
|
||||
public bool IsInitialized { get; private set; } = false;
|
||||
public bool IsLoaded { get; private set; } = false;
|
||||
public bool IsPlaying { get; private set; } = false;
|
||||
public bool IsPaused { get; private set; } = false;
|
||||
@@ -30,6 +31,8 @@ public class AudioPlaybackEngine : IAsyncDisposable
|
||||
|
||||
public async Task InitializeAudioPlayer()
|
||||
{
|
||||
if (IsInitialized) return;
|
||||
|
||||
var result = await AudioInterop.CreatePlayerAsync(PlayerId);
|
||||
if (!result.Success)
|
||||
{
|
||||
@@ -42,6 +45,8 @@ public class AudioPlaybackEngine : IAsyncDisposable
|
||||
await AudioInterop.SetOnLoadProgressCallbackAsync(PlayerId, OnLoadProgress);
|
||||
|
||||
await AudioInterop.SetVolumeAsync(PlayerId, Volume);
|
||||
|
||||
IsInitialized = true;
|
||||
}
|
||||
|
||||
public async Task LoadTrack(TrackEntity track)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using DeepDrftWeb.Client.Clients;
|
||||
using DeepDrftWeb.Client.Services;
|
||||
using DeepDrftWeb.Client.ViewModels;
|
||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||
using NetBlocks.Models;
|
||||
|
||||
namespace DeepDrftWeb.Client;
|
||||
|
||||
@@ -31,6 +29,6 @@ public static class Startup
|
||||
});
|
||||
services.AddScoped<TrackMediaClient>();
|
||||
services.AddScoped<AudioInteropService>();
|
||||
services.AddScoped<AudioPlaybackEngine>();
|
||||
services.AddTransient<AudioPlaybackEngine>();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,6 @@
|
||||
}
|
||||
},
|
||||
"ApiUrls": {
|
||||
"ContentApi": "https://localhost:54493/api"
|
||||
"ContentApi": "http://localhost:54493/api/"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
}
|
||||
},
|
||||
"ApiUrls": {
|
||||
"ContentApi": "https://media.deepdrft.com/api"
|
||||
"ContentApi": "https://media.deepdrft.com/api/"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user