Skip to content

Commit

Permalink
Added interaction with record control component
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Jul 2, 2024
1 parent 669eb02 commit 514d11e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 33 deletions.
45 changes: 22 additions & 23 deletions AudioCuesheetEditor/Pages/RecordControl.razor
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,23 @@ along with Foobar. If not, see
</Column>
</Row>

<ModalDialog @ref="modalDialog" />

@code {
//TODO: During countdown the StartRecord button is enabled, which allows the user to manually start the record
//TODO: Allow the user to edit the default RecordCountdownTimer
Timer updateGUITimer = new Timer(500);
Timer? startRecordTimer;
DateTime recordTimerStarted;

ModalDialog? modalDialog;

[Parameter]
public EventCallback StartRecordClicked { get; set; }

[Parameter]
public EventCallback StopRecordClicked { get; set; }

public void Dispose()
{
_localizationService.LocalizationChanged -= LocalizationService_LocalizationChanged;
Expand Down Expand Up @@ -106,7 +117,7 @@ along with Foobar. If not, see
}
};

//TODO: Attach to saved event and save the RecordCountdownTimer
//TODO: Attach to saved event and save the RecordCountdownTimer to adjust the timer when a new value was saved
var options = await _localStorageOptionsProvider.GetOptions<ApplicationOptions>();
startRecordTimer = new Timer(options.RecordCountdownTimer * 1000);
startRecordTimer.Elapsed += async delegate
Expand Down Expand Up @@ -148,31 +159,20 @@ along with Foobar. If not, see
//Check for empty cuesheet and warn!
if (_sessionStateContainer.Cuesheet.Tracks.Count > 0)
{
//TODO
// if (modalDialog != null)
// {
// modalDialog.Title = _localizer["Error"];
// modalDialog.Text = _localizer["Cuesheet already contains tracks. Recording is not possible, if tracks are present. Please save your work and start with a clean cuesheet."];
// modalDialog.ModalSize = ModalSize.Small;
// modalDialog.Mode = ModalDialog.DialogMode.Alert;
// await modalDialog.ShowModal();
// }
if (modalDialog != null)
{
modalDialog.Title = _localizer["Error"];
modalDialog.Text = _localizer["Cuesheet already contains tracks. Recording is not possible, if tracks are present. Please save your work and start with a clean cuesheet."];
modalDialog.ModalSize = ModalSize.Small;
modalDialog.Mode = ModalDialog.DialogMode.Alert;
await modalDialog.ShowModal();
}
}
else
{
_sessionStateContainer.Cuesheet.StartRecording();
//TODO
updateGUITimer.Start();
// await _jsRuntime.InvokeVoidAsync("startAudioRecording");
// if ((_sessionStateContainer.Cuesheet.Audiofile != null) && (_sessionStateContainer.Cuesheet.Audiofile.IsRecorded))
// {
// await _jsRuntime.InvokeVoidAsync("URL.revokeObjectURL", _sessionStateContainer.Cuesheet.Audiofile.ObjectURL);
// }
// _sessionStateContainer.Cuesheet.Audiofile = null;
// if (autocompleteArtist != null)
// {
// await autocompleteArtist.Focus();
// }
await StartRecordClicked.InvokeAsync();
}
}

Expand All @@ -188,9 +188,8 @@ along with Foobar. If not, see

async Task StopRecordingClicked()
{
//TODO
// await _jsRuntime.InvokeVoidAsync("stopAudioRecording");
var options = await _localStorageOptionsProvider.GetOptions<ApplicationOptions>();
_sessionStateContainer.Cuesheet.StopRecording(options);
await StopRecordClicked.InvokeAsync();
}
}
28 changes: 20 additions & 8 deletions AudioCuesheetEditor/Pages/ViewModeRecord.razor
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ along with Foobar. If not, see
<Button Clicked="(() => recordControlVisible = !recordControlVisible)"><Heading Size="HeadingSize.Is3">@_localizer["Recordcontrol"]</Heading></Button>
</CollapseHeader>
<CollapseBody>
<RecordControl />
<RecordControl StartRecordClicked="RecordingStarted" StopRecordClicked="RecordingStopped" />
</CollapseBody>
</Collapse>
<Collapse Visible="cuesheetDataVisible">
Expand Down Expand Up @@ -121,10 +121,7 @@ along with Foobar. If not, see
}
</Column>

<ModalDialog @ref="modalDialog" />

@code {
//TODO: Interaction with RecordControl component
public void Dispose()
{
_jsRuntime.InvokeVoidAsync("closeAudioRecording");
Expand All @@ -142,10 +139,6 @@ along with Foobar. If not, see
StateHasChanged();
}

DateTime recordTimerStarted;

ModalDialog? modalDialog;

Autocomplete<MusicBrainzArtist, Guid>? autocompleteArtist;
Autocomplete<MusicBrainzTrack, Guid>? autocompleteTitle;

Expand Down Expand Up @@ -264,4 +257,23 @@ along with Foobar. If not, see
}
}
}

async Task RecordingStarted()
{
await _jsRuntime.InvokeVoidAsync("startAudioRecording");
if ((_sessionStateContainer.Cuesheet.Audiofile != null) && (_sessionStateContainer.Cuesheet.Audiofile.IsRecorded))
{
await _jsRuntime.InvokeVoidAsync("URL.revokeObjectURL", _sessionStateContainer.Cuesheet.Audiofile.ObjectURL);
}
_sessionStateContainer.Cuesheet.Audiofile = null;
if (autocompleteArtist != null)
{
await autocompleteArtist.Focus();
}
}

async Task RecordingStopped()
{
await _jsRuntime.InvokeVoidAsync("stopAudioRecording");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"Start recording": "Aufnahme starten",
"Stop recording": "Aufnahme beenden",
"Start record timer": "Aufnahmecountdown starten",
"Record will start in {0} seconds!": "Aufnahme wird in {0} Sekunden starten!"
"Record will start in {0} seconds!": "Aufnahme wird in {0} Sekunden starten!",
"Error": "Fehler",
"Cuesheet already contains tracks. Recording is not possible, if tracks are present. Please save your work and start with a clean cuesheet.": "Das Cuesheet enthält bereits Titel. Die Aufnahme ist nicht möglich, wenn bereits Titel vorhanden sind. Bitte speichern Sie ihre Arbeit und starten Sie anschließend mit einem leeren Cuesheet."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"Start recording": "Start recording",
"Stop recording": "Stop recording",
"Start record timer": "Start record countdown timer",
"Record will start in {0} seconds!": "Record will start in {0} seconds!"
"Record will start in {0} seconds!": "Record will start in {0} seconds!",
"Error": "Error",
"Cuesheet already contains tracks. Recording is not possible, if tracks are present. Please save your work and start with a clean cuesheet.": "Cuesheet already contains tracks. Recording is not possible, if tracks are present. Please save your work and start with a clean cuesheet."
}
}

0 comments on commit 514d11e

Please sign in to comment.