Skip to content

Commit

Permalink
Merge pull request #24 from strem-app/feature/add-more-obs-flow-elements
Browse files Browse the repository at this point in the history
Feature/add more obs flow elements
  • Loading branch information
grofit authored Aug 26, 2022
2 parents 4b419a7 + e2aa427 commit 32b2843
Show file tree
Hide file tree
Showing 44 changed files with 1,092 additions and 204 deletions.
5 changes: 4 additions & 1 deletion src/Strem.Core/Components/Elements/AutoComplete.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</div>
<div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content">
@foreach (var entry in CurrentMatches)
@foreach (var entry in CurrentMatches.Take(MaxResults))
{
var entryText = entry;
<a class="dropdown-item has-text-black" @onclick="() => SetSelection(entryText)">
Expand All @@ -28,6 +28,9 @@

[Parameter]
public IReadOnlyCollection<string> Data { get; set; }

[Parameter]
public int MaxResults { get; set; } = 10;

public IEnumerable<string> CurrentMatches { get; set; }

Expand Down
1 change: 1 addition & 0 deletions src/Strem.Core/Components/Elements/ProcessedInput.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using System.Text.RegularExpressions

<div class="control has-icons-left">

<input class="input @(InputVisible ? "" : "is-hidden")" type="text" placeholder="@Placeholder" value="@Value" @onblur="HideInput"
Expand Down
16 changes: 15 additions & 1 deletion src/Strem.Core/Components/VariableDescriptorList.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
@using Strem.Core.Flows
@using Strem.Core.Variables
@using Strem.Core.Events.Bus
@using Strem.Core.Events
@using TextCopy

@inject IJSRuntime JS

<div class="field is-grouped is-grouped-multiline">
@foreach (var descriptor in VariableDescriptors)
{
<div class="control">
<div class="tags has-addons">
<div class="tags has-addons is-clickable" @onclick="() => CopyVariableToClipboard(descriptor.VariableEntry)">
<span class="tag @(descriptor.IsMandatory ? "is-success" : "is-warning")">@descriptor.VariableEntry.Name</span>
@if (!string.IsNullOrEmpty(descriptor.VariableEntry.Context))
{
Expand All @@ -18,4 +24,12 @@
@code {
[Parameter]
public VariableDescriptor[] VariableDescriptors { get; set; }

private async Task CopyVariableToClipboard(VariableEntry variableEntry)
{
var variableText = $"V({variableEntry.Name}{(variableEntry.HasContext ? $",{variableEntry.Context}" : "")})";
await ClipboardService.SetTextAsync(variableText);
await JS.InvokeVoidAsync("showNotification", "Copied Variable To Clipboard", "is-info");
}

}
13 changes: 13 additions & 0 deletions src/Strem.Core/Events/ShowNotificationEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Strem.Core.Events;

public class ShowNotificationEvent
{
public string Classes { get; }
public string Message { get; }

public ShowNotificationEvent(string message, string classes = null)
{
Classes = classes;
Message = message;
}
}
8 changes: 2 additions & 6 deletions src/Strem.Core/Strem.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
<HintPath>C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\6.0.7\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<PackageReference Include="TextCopy" Version="6.1.0" />
</ItemGroup>

</Project>
92 changes: 51 additions & 41 deletions src/Strem.OBS/Components/Integrations/OBSIntegration.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,53 @@

@implements IDisposable

<label class="label">OBS Host/IP & Port</label>
<div class="field has-addons">
<div class="control">
<input class="input" type="text" placeholder="i.e localhost or 127.0.0.1" @bind="Host"/>
</div>
<div class="control">
<label class="label m-2">:</label>
</div>
<div class="control">
<input class="input" type="text" placeholder="i.e 4444" @bind="Port"/>
<div class="columns">
<div class="column">
<label class="label">OBS Host/IP & Port</label>
<div class="field has-addons">
<div class="control is-expanded">
<input class="input" type="text" placeholder="i.e localhost or 127.0.0.1" @bind="Host"/>
</div>
<div class="control">
<label class="label m-2">:</label>
</div>
<div class="control">
<input class="input" type="text" placeholder="i.e 4444" @bind="Port"/>
</div>
</div>
<div class="field">
<div class="control">
@if (IsConnected)
{
<button class="button is-danger" @onclick="DisconnectFromOBS" disabled="@IsConnecting">Disconnect From OBS</button>
}
else
{
<button class="button is-success" @onclick="ConnectToOBS" disabled="@IsConnecting">Connect To OBS</button>
}
</div>
@if (!string.IsNullOrEmpty(ConnectionError))
{
<p class="help">
<span class="icon has-text-danger">
<i class="fas fa-circle-exclamation"></i>
</span>
<span class="has-text-danger">
@ConnectionError
</span>
</p>
}
</div>
</div>
</div>
<div class="field">
<label class="label">OBS Server Password</label>
<div class="control">
<input class="input" type="password" @bind="Password"/>
<div class="column">
<div class="field">
<label class="label">OBS Server Password</label>
<div class="control">
<input class="input" type="password" @bind="Password"/>
</div>
<HelperInfo>You can leave the password empty if there is no password set on the server</HelperInfo>
</div>
</div>
<HelperInfo>You can leave the password empty if there is no password set on the server</HelperInfo>
</div>
<div class="field">
<div class="control">
@if (IsConnected)
{
<button class="button is-danger" @onclick="DisconnectFromOBS" disabled="@IsConnecting">Disconnect From OBS</button>
}
else
{
<button class="button is-success" @onclick="ConnectToOBS" disabled="@IsConnecting">Connect To OBS</button>
}
</div>
@if (!string.IsNullOrEmpty(ConnectionError))
{
<p class="help">
<span class="icon has-text-danger">
<i class="fas fa-circle-exclamation"></i>
</span>
<span class="has-text-danger">
@ConnectionError
</span>
</p>
}
</div>

@code {
Expand Down Expand Up @@ -92,8 +98,8 @@
InvokeAsync(StateHasChanged);

var result = await ObsClient.AttemptConnect(Host, Port, Password);
ConnectionError = result.message;

ConnectionError = string.Empty;
if (result.success)
{
AppState.AppVariables.Delete(OBSVars.Password);
Expand All @@ -105,6 +111,10 @@
AppState.AppVariables.Set(OBSVars.Password, encryptedPassword);
}
}
else
{
ConnectionError = result.message;
}

IsConnecting = false;
InvokeAsync(StateHasChanged);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@using Microsoft.AspNetCore.Components
@using Strem.Core.Components.Tasks
@using Strem.Core.State
@using Strem.OBS.Extensions
@using Strem.OBS.Flows.Tasks
@using Strem.OBS.Services.Client
@using Strem.OBS.Types

@inherits CustomTaskComponent<ChangeSceneTaskData>

@inject IAppState AppState;
@inject IObservableOBSClient ObsClient;

<div class="field">
<label class="label">Scene Name</label>
<div class="control">
<AutoComplete @bind-Value="@Data.NewScene" Data="SceneNames"></AutoComplete>
</div>
</div>

@code {
public override string Title => $"Change Scene To {Data.NewScene}";

public string[] SceneNames { get; set; } = Array.Empty<string>();

protected override async Task OnInitializedAsync()
{
if (ObsClient.IsConnected)
{
var scenes = await ObsClient.GetSceneList();
SceneNames = scenes.Scenes.Select(x => x.Name).ToArray();
}
else
{
SceneNames = Array.Empty<string>();
}

await base.OnInitializedAsync();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@using Microsoft.AspNetCore.Components
@using Strem.Core.Components.Tasks
@using Strem.OBS.Flows.Tasks

@inherits CustomTaskComponent<SetRecordingStateTaskData>

<div class="field">
<label class="label">Stream Operation</label>
<div class="control">
<TrueOrFalse @bind-Value="Data.StartRecording" TrueText="Start Recording" FalseText="Stop Recording"></TrueOrFalse>
</div>
</div>


@code {
public override string Title => GetTitle();

public string GetTitle()
{
var starter = Data.StartRecording ? "Start" : "Stop";
return $"<strong>{starter}</strong> OBS Recording";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@

protected override async Task OnInitializedAsync()
{
if (AppState.HasOBSHost() && ObsClient.IsConnected)
if (ObsClient.IsConnected)
{
if (!AppState.HasCurrentSceneItems())
{ await ObsClient.PopulateActiveSceneTransientData(AppState); }
CurrentSceneItems = AppState.GetCurrentSceneItems();
if (!AppState.HasSourceList())
{ await ObsClient.PopulateSourceListData(AppState); }
CurrentSceneItems = AppState.GetSourceList();
}
else
{ CurrentSceneItems = Array.Empty<string>(); }

await base.OnInitializedAsync();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
{
if (AppState.HasOBSHost() && ObsClient.IsConnected)
{
if (!AppState.HasCurrentSceneItems())
{ await ObsClient.PopulateActiveSceneTransientData(AppState); }
CurrentSceneItems = AppState.GetCurrentSceneItems();
if (!AppState.HasSourceList())
{ await ObsClient.PopulateSourceListData(AppState); }
CurrentSceneItems = AppState.GetSourceList();
}
else
{ CurrentSceneItems = Array.Empty<string>(); }

await base.OnInitializedAsync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@using Microsoft.AspNetCore.Components
@using Strem.Core.Components.Tasks
@using Strem.Core.State
@using Strem.OBS.Extensions
@using Strem.OBS.Flows.Tasks
@using Strem.OBS.Services.Client
@using Strem.OBS.Types

@inherits CustomTaskComponent<SetStreamStateTaskData>

<div class="field">
<label class="label">Stream Operation</label>
<div class="control">
<TrueOrFalse @bind-Value="Data.StartStream" TrueText="Start Stream" FalseText="Stop Stream"></TrueOrFalse>
</div>
</div>


@code {
public override string Title => GetTitle();

public string GetTitle()
{
var starter = Data.StartStream ? "Start" : "Stop";
return $"<strong>{starter}</strong> OBS Stream";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@

protected override async Task OnInitializedAsync()
{
if (AppState.HasOBSHost() && ObsClient.IsConnected)
if (ObsClient.IsConnected)
{
if (!AppState.HasCurrentSceneItems())
{ await ObsClient.PopulateActiveSceneTransientData(AppState); }
CurrentSceneItems = AppState.GetCurrentSceneItems();
if (!AppState.HasSourceList())
{ await ObsClient.PopulateSourceListData(AppState); }
CurrentSceneItems = AppState.GetSourceList();
}
else
{ CurrentSceneItems = Array.Empty<string>(); }

await base.OnInitializedAsync();
}
}
Loading

0 comments on commit 32b2843

Please sign in to comment.