-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
817fb52
commit 1e84441
Showing
12 changed files
with
295 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...zor.WebAudio.WasmExample/AudioEditor/MenuItems/AddNewMediaStreamAudioSourceMenuItem.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@using BlazorContextMenu | ||
<Item OnClick="_ => MediaStreamAudioSource.AddNew(SVGEditor)"><div class="icon">🎤</div> New MediaStream Source</Item> | ||
@code { | ||
[CascadingParameter] | ||
public required SVGEditor.SVGEditor SVGEditor { get; set; } | ||
|
||
[Parameter] | ||
public required object Data { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...be.Blazor.WebAudio.WasmExample/AudioEditor/NodeEditors/MediaStreamAudioSourceEditor.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
@using BlazorContextMenu | ||
@using KristofferStrube.Blazor.SVGEditor.Extensions | ||
@inherits NodeEditor<MediaStreamAudioSource> | ||
|
||
<ContextMenuTrigger MenuId="SVGMenu" WrapperTag="g" Data=@SVGElement MouseButtonTrigger="SVGElement.ShouldTriggerContextMenu ? MouseButtonTrigger.Right : (MouseButtonTrigger)4"> | ||
<g transform="translate(@SVGElement.SVG.Translate.x.AsString() @SVGElement.SVG.Translate.y.AsString()) scale(@SVGElement.SVG.Scale.AsString())"> | ||
<rect @ref=ElementReference | ||
@onfocusin="FocusElement" | ||
@onfocusout="UnfocusElement" | ||
@onpointerdown="SelectAsync" | ||
@onkeyup="KeyUp" | ||
tabindex="@(SVGElement.IsChildElement ? -1 : 0)" | ||
x=@SVGElement.X.AsString() | ||
y=@SVGElement.Y.AsString() | ||
width=@SVGElement.Width.AsString() | ||
height=@SVGElement.Height.AsString() | ||
stroke="@SVGElement.Stroke" | ||
stroke-width="@SVGElement.StrokeWidth" | ||
stroke-linecap="@SVGElement.StrokeLinecap.AsString()" | ||
stroke-linejoin="@SVGElement.StrokeLinejoin.AsString()" | ||
stroke-dasharray="@SVGElement.StrokeDasharray" | ||
stroke-dashoffset="@SVGElement.StrokeDashoffset.AsString()" | ||
fill="@SVGElement.Fill" | ||
style="filter:brightness(@(SVGElement.Selected ? "0.9" : "1"))"> | ||
</rect> | ||
<foreignObject @onpointermove:stopPropagation=!ChildContentIsNoninteractive x="@((SVGElement.X+10).AsString())" y="@((SVGElement.Y+10).AsString())" height="80" width="200" style="border:solid @(SVGElement.StrokeWidth)px @(SVGElement.Stroke);padding:2;pointer-events:@(ChildContentIsNoninteractive ? "none" : "inherit");touch-action:@(ChildContentIsNoninteractive ? "none" : "inherit");"> | ||
<label for="audioSource">MediaStream Source</label> | ||
@if (SVGElement.AudioOptions.Count > 0) | ||
{ | ||
<select id="audioSource" @bind=SVGElement.SelectedAudioSource @bind:after="SetMediaStreamAudioSourceNode"> | ||
@foreach (var option in SVGElement.AudioOptions) | ||
{ | ||
<option value="@option.id" selected="@(option.id == SVGElement.SelectedAudioSource)">@option.label</option> | ||
} | ||
</select> | ||
} | ||
</foreignObject> | ||
<ContextMenuTrigger MenuId="SVGMenu" WrapperTag="g" Data=@(new Port(SVGElement, 0, false)) MouseButtonTrigger="SVGElement.ShouldTriggerContextMenu ? MouseButtonTrigger.Right : (MouseButtonTrigger)4"> | ||
<circle cx=@((SVGElement.X+SVGElement.Width).AsString()) cy="@((SVGElement.Y+20).AsString())" r="10" fill="grey"> | ||
|
||
</circle> | ||
</ContextMenuTrigger> | ||
</g> | ||
</ContextMenuTrigger> | ||
|
||
@code { | ||
private MediaStreamAudioSourceNode? mediaStreamAudioSourceNode; | ||
|
||
[CascadingParameter] | ||
public required AudioContext AudioContext { get; set; } | ||
|
||
protected override async Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
await base.OnAfterRenderAsync(firstRender); | ||
|
||
if (mediaStreamAudioSourceNode is null && AudioContext is not null) | ||
{ | ||
mediaStreamAudioSourceNode = (MediaStreamAudioSourceNode)await SVGElement.AudioNode(AudioContext); | ||
StateHasChanged(); | ||
} | ||
} | ||
|
||
protected async Task SetMediaStreamAudioSourceNode() | ||
{ | ||
await SVGElement.SetMediaStreamAudioSourceNode(AudioContext); | ||
StateHasChanged(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.