Compare commits

10 Commits

Author SHA1 Message Date
bc40f9abe3 socket set up properly 2026-02-26 15:48:41 -05:00
e7f649ae0b * 'Line 1: Added 'using Newtonsoft.Json.Serialization;' to ensure that JsonPropertyAttribute is available, as it is defined in this namespace in Newtonsoft.Json.' in file 'stream_deck_plugin\ClipTrimDotNet\Client\ClipMetadata.cs' 2026-02-24 21:16:25 -05:00
e34903b20f * 'Line 3: Removed the duplicate using directive for Newtonsoft.Json.Converters.' in file 'stream_deck_plugin\ClipTrimDotNet\Client\ClipMetadata.cs' 2026-02-24 21:16:18 -05:00
192c959d39 * 'Line 1: Ensure both 'Newtonsoft.Json' and 'Newtonsoft.Json.Converters' namespaces are included, as JsonPropertyAttribute and StringEnumConverter are defined in these namespaces. This resolves the CS0246 error for missing JsonPropertyAttribute.' in file 'stream_deck_plugin\ClipTrimDotNet\Client\ClipMetadata.cs' 2026-02-24 21:16:12 -05:00
60123d7450 * 'Line 37: Replaced [JsonProperty(PropertyName = path)] with [JsonPropertyName(path)] to use the System.Text.Json.Serialization.JsonPropertyNameAttribute, which is available in .NET 8 and the current project.
Line 40: Replaced [JsonProperty(PropertyName = index)] with [JsonPropertyName(index)] to use the correct attribute from System.Text.Json.Serialization.
Line 42: Replaced [JsonProperty(PropertyName = playtype)] with [JsonPropertyName(playtype)] to use the correct attribute from System.Text.Json.Serialization.
Line 45: Replaced [JsonProperty(PropertyName = volume)] with [JsonPropertyName(volume)] to use the correct attribute from System.Text.Json.Serialization.
Line 5: Replaced the using directive for Newtonsoft.Json with System.Text.Json.Serialization, as the project does not reference Newtonsoft.Json and should use System.Text.Json.Serialization.JsonPropertyNameAttribute instead.' in file 'stream_deck_plugin\ClipTrimDotNet\Player.cs'
2026-02-24 21:16:05 -05:00
8265951bd4 Move assembly metadata to .csproj and clean AssemblyInfo.cs
Assembly metadata such as title, product, copyright, and version information was moved from Properties/AssemblyInfo.cs to the ClipTrimDotNet.csproj file. The corresponding attributes and comments were removed from AssemblyInfo.cs, leaving only the trademark, culture, and GUID attributes. This streamlines project configuration and centralizes assembly information in the project file.
2026-02-24 21:15:31 -05:00
757d5ef1a7 Update package versions in ClipTrimDotNet.csproj
Upgraded several NuGet package dependencies in ClipTrimDotNet.csproj, including Microsoft.Extensions.* packages, System.* packages, and System.Drawing.Common, from version 8.x to 10.x or 9.x where applicable. This ensures compatibility with newer frameworks and libraries, and may provide bug fixes and performance improvements. No other files were modified.
2026-02-24 21:15:29 -05:00
d78c49d0ad Update ClipTrimDotNet.csproj dependencies to latest versions
Modernized the ClipTrimDotNet.csproj by upgrading several Microsoft.Extensions and System.* package references to their latest 8.x versions, replacing or removing older references. Added new CoreWCF packages and System.Configuration.ConfigurationManager for enhanced WCF and configuration support. Cleaned up unused or redundant references to streamline the project dependencies.
2026-02-24 21:14:40 -05:00
089023e7cf Refactor ClipTrimDotNet.csproj to SDK style and .NET 8
Converted the project file to the modern SDK-style format, targeting .NET 8.0 instead of .NET Framework 4.8. Replaced explicit assembly references and manual NuGet package management with <PackageReference> elements for all dependencies. Removed legacy MSBuild properties, imports, and targets, simplifying the project structure. Updated build events and ensured content files are copied as needed. This modernization improves maintainability and compatibility with current .NET tooling.
2026-02-24 21:14:28 -05:00
db97747f2e Commit upgrade plan 2026-02-24 21:13:55 -05:00
16 changed files with 383 additions and 495 deletions

70
.github/upgrades/dotnet-upgrade-plan.md vendored Normal file
View File

@ -0,0 +1,70 @@
# .NET 8.0 Upgrade Plan
## Execution Steps
Execute steps below sequentially one by one in the order they are listed.
1. Validate that an .NET 8.0 SDK required for this upgrade is installed on the machine and if not, help to get it installed.
2. Ensure that the SDK version specified in global.json files is compatible with the .NET 8.0 upgrade.
3. Upgrade ClipTrimDotNet\ClipTrimDotNet.csproj
4. Run unit tests to validate upgrade in the projects listed below:
- ClientTest\ClientTest.csproj
## Settings
This section contains settings and data used by execution steps.
### Excluded projects
| Project name | Description |
|:-----------------------------------------------|:---------------------------:|
### Aggregate NuGet packages modifications across all projects
NuGet packages used across all selected projects or their dependencies that need version update in projects that reference them.
| Package Name | Current Version | New Version | Description |
|:------------------------------------|:---------------:|:-----------:|:----------------------------------------------|
| Microsoft.Bcl.AsyncInterfaces | 10.0.2 | 8.0.0 | Recommended for .NET 8.0 |
| Microsoft.Extensions.DependencyInjection | 10.0.2 | 8.0.1 | Recommended for .NET 8.0 |
| Microsoft.Extensions.DependencyInjection.Abstractions | 10.0.2 | 8.0.2 | Recommended for .NET 8.0 |
| Microsoft.Extensions.Logging | 10.0.2 | 8.0.1 | Recommended for .NET 8.0 |
| Microsoft.Extensions.Logging.Abstractions | 10.0.2 | 8.0.3 | Recommended for .NET 8.0 |
| Microsoft.Extensions.Options | 10.0.2 | 8.0.2 | Recommended for .NET 8.0 |
| Microsoft.Extensions.Primitives | 10.0.2 | 8.0.0 | Recommended for .NET 8.0 |
| System.Diagnostics.DiagnosticSource | 10.0.2 | 8.0.1 | Recommended for .NET 8.0 |
| System.Drawing.Common | 9.0.10 | 8.0.24 | Recommended for .NET 8.0 |
| System.IO.Pipelines | 10.0.2 | 8.0.0 | Recommended for .NET 8.0 |
| System.Security.AccessControl | 4.7.0 | 6.0.1 | Recommended for .NET 8.0 |
| System.Text.Encodings.Web | 10.0.2 | 8.0.0 | Recommended for .NET 8.0 |
| System.Text.Json | 10.0.2 | 8.0.6 | Recommended for .NET 8.0 |
| Microsoft.Win32.Registry | 4.7.0 | | Functionality included with framework |
| System.Buffers | 4.6.1 | | Functionality included with framework |
| System.IO | 4.3.0 | | Functionality included with framework |
| System.Memory | 4.6.3 | | Functionality included with framework |
| System.Net.Http | 4.3.4 | | Functionality included with framework |
| System.Numerics.Vectors | 4.6.1 | | Functionality included with framework |
| System.Runtime | 4.3.0 | | Functionality included with framework |
| System.Security.Cryptography.Algorithms | 4.3.0 | | Functionality included with framework |
| System.Security.Cryptography.Encoding | 4.3.0 | | Functionality included with framework |
| System.Security.Cryptography.Primitives | 4.3.0 | | Functionality included with framework |
| System.Security.Cryptography.X509Certificates | 4.3.0 | | Functionality included with framework |
| System.Security.Principal.Windows | 4.7.0 | | Functionality included with framework |
| System.Threading.Tasks.Extensions | 4.6.3 | | Functionality included with framework |
| System.ValueTuple | 4.6.1 | | Functionality included with framework |
### Project upgrade details
#### ClipTrimDotNet\ClipTrimDotNet.csproj modifications
Project properties changes:
- Target framework should be changed from `.NETFramework,Version=v4.8` to `net8.0`
- Project file should be converted to SDK-style
NuGet packages changes:
- Update all packages listed in the NuGet packages table above as recommended
- Remove packages whose functionality is now included with the framework
Other changes:
- Ensure compatibility with .NET 8.0 APIs and features
- Update code as needed for breaking changes

View File

@ -95,7 +95,7 @@ class MetaDataManager:
collection["clips"] = new_order collection["clips"] = new_order
if not self.socket is None: if not self.socket is None:
self.socket.emit('collection_updated', {'collection': collection}) self.socket.emit('collection_updated', collection)
self.save_metadata() self.save_metadata()
def save_metadata(self): def save_metadata(self):

View File

@ -28,4 +28,5 @@ def set_all_settings():
SettingsManager().set_settings(name, value) SettingsManager().set_settings(name, value)
return jsonify({'status': 'success', 'settings': settings}) return jsonify({'status': 'success', 'settings': settings})
except ValueError as e: except ValueError as e:
return jsonify({'status': 'error', 'message': str(e)}), 400 return jsonify({'status': 'error', 'message': str(e)}), 400

View File

@ -5,8 +5,6 @@ VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClipTrimDotNet", "ClipTrimDotNet\ClipTrimDotNet.csproj", "{4635D874-69C0-4010-BE46-77EF92EB1553}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClipTrimDotNet", "ClipTrimDotNet\ClipTrimDotNet.csproj", "{4635D874-69C0-4010-BE46-77EF92EB1553}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientTest", "ClientTest\ClientTest.csproj", "{245B4C42-D83B-4381-8B79-ECC11238CD88}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -17,10 +15,6 @@ Global
{4635D874-69C0-4010-BE46-77EF92EB1553}.Debug|Any CPU.Build.0 = Debug|Any CPU {4635D874-69C0-4010-BE46-77EF92EB1553}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4635D874-69C0-4010-BE46-77EF92EB1553}.Release|Any CPU.ActiveCfg = Release|Any CPU {4635D874-69C0-4010-BE46-77EF92EB1553}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4635D874-69C0-4010-BE46-77EF92EB1553}.Release|Any CPU.Build.0 = Release|Any CPU {4635D874-69C0-4010-BE46-77EF92EB1553}.Release|Any CPU.Build.0 = Release|Any CPU
{245B4C42-D83B-4381-8B79-ECC11238CD88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{245B4C42-D83B-4381-8B79-ECC11238CD88}.Debug|Any CPU.Build.0 = Debug|Any CPU
{245B4C42-D83B-4381-8B79-ECC11238CD88}.Release|Any CPU.ActiveCfg = Release|Any CPU
{245B4C42-D83B-4381-8B79-ECC11238CD88}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -1,10 +1,13 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Text.Json.Serialization;
namespace ClipTrimDotNet.Client namespace ClipTrimDotNet.Client
{ {
@ -16,27 +19,35 @@ namespace ClipTrimDotNet.Client
public class ClipMetadata public class ClipMetadata
{ {
[JsonProperty(PropertyName = "filename")] [JsonProperty(PropertyName = "filename")]
[JsonPropertyName("filename")]
public string Filename { get; set; } public string Filename { get; set; }
[JsonProperty(PropertyName = "name")] [JsonProperty(PropertyName = "name")]
[JsonPropertyName("name")]
public string Name { get; set; } public string Name { get; set; }
[JsonProperty(PropertyName = "volume")] [JsonProperty(PropertyName = "volume")]
[JsonPropertyName("volume")]
public double Volume { get; set; } = 1.0; public double Volume { get; set; } = 1.0;
[JsonProperty(PropertyName = "startTime")] [JsonProperty(PropertyName = "startTime")]
[JsonPropertyName("startTime")]
public double StartTime { get; set; } = 0.0; public double StartTime { get; set; } = 0.0;
[JsonProperty(PropertyName = "endTime")] [JsonProperty(PropertyName = "endTime")]
[JsonPropertyName("endTime")]
public double EndTime { get; set; } = 0.0; public double EndTime { get; set; } = 0.0;
[JsonProperty(PropertyName = "playbackType")] [JsonProperty(PropertyName = "playbackType")]
[JsonConverter(typeof(StringEnumConverter))] [Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
[System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))]
[JsonPropertyName("playbackType")]
public PlaybackType PlaybackType { get; set; } = PlaybackType.playStop; public PlaybackType PlaybackType { get; set; } = PlaybackType.playStop;
} }
} }

View File

@ -38,6 +38,7 @@ namespace ClipTrimDotNet.Client
// BaseAddress = new Uri("http://localhost:5010/"), // BaseAddress = new Uri("http://localhost:5010/"),
// Timeout = TimeSpan.FromSeconds(10) // Timeout = TimeSpan.FromSeconds(10)
//}; //};
Logger.Instance.LogMessage(TracingLevel.INFO, $"Starting ClipTrimClient on port {PortNumber}");
socket = new SocketIO(new Uri($"http://localhost:5010/")); socket = new SocketIO(new Uri($"http://localhost:5010/"));
socket.Options.AutoUpgrade = false; socket.Options.AutoUpgrade = false;
socket.Options.ConnectionTimeout = TimeSpan.FromSeconds(10); socket.Options.ConnectionTimeout = TimeSpan.FromSeconds(10);
@ -46,11 +47,14 @@ namespace ClipTrimDotNet.Client
{ {
try try
{ {
Collections = JsonConvert.DeserializeObject<List<CollectionMetaData>>(ctx.RawText); var response = ctx.GetValue<List<CollectionMetaData>>(0);
Logger.Instance.LogMessage(TracingLevel.INFO, $"full_data event {JsonConvert.SerializeObject(response)}");
Collections = response!;
//Logger.Instance.LogMessage(TracingLevel.INFO, $"Collections {JsonConvert.SerializeObject(Collections)}");
} }
catch catch (Exception ex)
{ {
Logger.Instance.LogMessage(TracingLevel.INFO, $"full_data error {ex.ToString()}");
} }
return Task.CompletedTask; return Task.CompletedTask;
}); });
@ -58,18 +62,19 @@ namespace ClipTrimDotNet.Client
{ {
try try
{ {
var collection = JsonConvert.DeserializeObject<CollectionMetaData>(ctx.RawText); var response = ctx.GetValue<CollectionMetaData>(0)!;
int index = Collections.FindIndex(x => x.Id == collection.Id); Logger.Instance.LogMessage(TracingLevel.INFO, $"collection_updated event {JsonConvert.SerializeObject(response)}");
if(index != -1) int index = Collections.FindIndex(x => x.Id == response.Id);
if (index != -1)
{ {
Collections[index] = collection; Collections[index] = response;
} }
} }
catch catch
{ {
} }
return Task.CompletedTask; return Task.CompletedTask;
}); });
@ -89,7 +94,7 @@ namespace ClipTrimDotNet.Client
//} //}
public List<CollectionMetaData> Collections { get; private set; } = new List<CollectionMetaData>(); public List<CollectionMetaData> Collections { get; private set; } = new List<CollectionMetaData>();
public CollectionMetaData? SelectedCollection { get; private set; } public int SelectedCollection { get; private set; } = -1;
public int PageIndex { get; private set; } = 0; public int PageIndex { get; private set; } = 0;
//private async Task GetMetadata() //private async Task GetMetadata()
//{ //{
@ -120,21 +125,21 @@ namespace ClipTrimDotNet.Client
public void SetSelectedCollectionByName(string name) public void SetSelectedCollectionByName(string name)
{ {
var collection = Collections.FirstOrDefault(x => x.Name == name); SelectedCollection = Collections.FindIndex(x => x.Name == name);
if (collection != null) if (SelectedCollection != -1)
{ {
SelectedCollection = collection;
PageIndex = 0; PageIndex = 0;
} }
} }
public ClipMetadata? GetClipByPagedIndex(int index) public ClipMetadata? GetClipByPagedIndex(int index)
{ {
if (SelectedCollection == null) return null; if (SelectedCollection == -1) return null;
int clipIndex = PageIndex * 10 + index; int clipIndex = PageIndex * 10 + index;
if (clipIndex >= 0 && clipIndex < SelectedCollection.Clips.Count) var collection = Collections[SelectedCollection];
if (clipIndex >= 0 && clipIndex < collection.Clips.Count)
{ {
return SelectedCollection.Clips[clipIndex]; return collection.Clips[clipIndex];
} }
return null; return null;
} }

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ClipTrimDotNet.Client namespace ClipTrimDotNet.Client
@ -10,14 +11,17 @@ namespace ClipTrimDotNet.Client
public class CollectionMetaData public class CollectionMetaData
{ {
[JsonProperty(PropertyName = "name")] [JsonProperty(PropertyName = "name")]
[JsonPropertyName("name")]
public string Name { get; set; } public string Name { get; set; }
[JsonProperty(PropertyName = "clips")] [JsonProperty(PropertyName = "clips")]
[JsonPropertyName("clips")]
public List<ClipMetadata> Clips { get; set; } = new List<ClipMetadata>(); public List<ClipMetadata> Clips { get; set; } = new List<ClipMetadata>();
[JsonProperty(PropertyName = "id")] [JsonProperty(PropertyName = "id")]
[JsonPropertyName("id")]
public int Id { get; set; } public int Id { get; set; }
} }
} }

View File

@ -1,221 +1,62 @@
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk">
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <TargetFramework>net8.0-windows</TargetFramework>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ProjectGuid>{4635D874-69C0-4010-BE46-77EF92EB1553}</ProjectGuid>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>ClipTrimDotNet</RootNamespace> <LangVersion>10</LangVersion>
<AssemblyName>ClipTrimDotNet</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<LangVersion>8</LangVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<TargetFrameworkProfile /> <ImplicitUsings>enable</ImplicitUsings>
<NuGetPackageImportStamp> <PreBuildEvent>npm run stop</PreBuildEvent>
</NuGetPackageImportStamp> <PostBuildEvent>npm run start</PostBuildEvent>
<AssemblyTitle>ClipTrimDotNet</AssemblyTitle>
<Product>ClipTrimDotNet</Product>
<Copyright>Copyright © 2020</Copyright>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\com.michal-courson.cliptrim.sdPlugin\</OutputPath> <OutputPath>bin\Debug\com.michal-courson.cliptrim.sdPlugin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\ClipTrimDotNet.sdPlugin\</OutputPath> <OutputPath>bin\Release\ClipTrimDotNet.sdPlugin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="CommandLine, Version=2.9.1.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL"> <PackageReference Include="CommandLineParser" Version="2.9.1" />
<HintPath>..\packages\CommandLineParser.2.9.1\lib\net461\CommandLine.dll</HintPath> <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
</Reference> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.2" />
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=10.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.2" />
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.10.0.2\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath> <PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.2" />
</Reference> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.2" />
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=10.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> <PackageReference Include="Microsoft.Extensions.Options" Version="10.0.2" />
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.10.0.2\lib\net462\Microsoft.Extensions.DependencyInjection.dll</HintPath> <PackageReference Include="Microsoft.Extensions.Primitives" Version="10.0.2" />
</Reference> <PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=10.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> <PackageReference Include="NLog" Version="6.0.5" />
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.10.0.2\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath> <PackageReference Include="SocketIOClient" Version="4.0.0.2" />
</Reference> <PackageReference Include="SocketIOClient.Common" Version="4.0.0" />
<Reference Include="Microsoft.Extensions.Logging, Version=10.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> <PackageReference Include="SocketIOClient.Serializer" Version="4.0.0.1" />
<HintPath>..\packages\Microsoft.Extensions.Logging.10.0.2\lib\net462\Microsoft.Extensions.Logging.dll</HintPath> <PackageReference Include="SocketIOClient.Serializer.NewtonsoftJson" Version="4.0.0.1" />
</Reference> <PackageReference Include="StreamDeck-Tools" Version="6.3.2" />
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=10.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="10.0.2" />
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.10.0.2\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath> <PackageReference Include="System.Drawing.Common" Version="9.0.10" />
</Reference> <PackageReference Include="System.IO.Pipelines" Version="10.0.2" />
<Reference Include="Microsoft.Extensions.Options, Version=10.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.2" />
<HintPath>..\packages\Microsoft.Extensions.Options.10.0.2\lib\net462\Microsoft.Extensions.Options.dll</HintPath> <PackageReference Include="System.Security.AccessControl" Version="6.0.1" />
</Reference> <PackageReference Include="System.Text.Encodings.Web" Version="10.0.2" />
<Reference Include="Microsoft.Extensions.Primitives, Version=10.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> <PackageReference Include="System.Text.Json" Version="10.0.2" />
<HintPath>..\packages\Microsoft.Extensions.Primitives.10.0.2\lib\net462\Microsoft.Extensions.Primitives.dll</HintPath> <PackageReference Include="System.Configuration.ConfigurationManager" Version="10.0.3" />
</Reference> <PackageReference Include="CoreWCF.Primitives" Version="1.8.0" />
<Reference Include="Microsoft.Win32.Registry, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <PackageReference Include="CoreWCF.ConfigurationManager" Version="1.8.0" />
<HintPath>..\packages\Microsoft.Win32.Registry.4.7.0\lib\net461\Microsoft.Win32.Registry.dll</HintPath> <PackageReference Include="CoreWCF.Http" Version="1.8.0" />
</Reference> <PackageReference Include="CoreWCF.WebHttp" Version="1.8.0" />
<Reference Include="NAudio, Version=2.2.1.0, Culture=neutral, PublicKeyToken=e279aa5131008a41, processorArchitecture=MSIL"> <PackageReference Include="CoreWCF.NetTcp" Version="1.8.0" />
<HintPath>..\packages\NAudio.2.2.1\lib\net472\NAudio.dll</HintPath>
</Reference>
<Reference Include="NAudio.Asio, Version=2.2.1.0, Culture=neutral, PublicKeyToken=e279aa5131008a41, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.Asio.2.2.1\lib\netstandard2.0\NAudio.Asio.dll</HintPath>
</Reference>
<Reference Include="NAudio.Core, Version=2.2.1.0, Culture=neutral, PublicKeyToken=e279aa5131008a41, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.Core.2.2.1\lib\netstandard2.0\NAudio.Core.dll</HintPath>
</Reference>
<Reference Include="NAudio.Midi, Version=2.2.1.0, Culture=neutral, PublicKeyToken=e279aa5131008a41, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.Midi.2.2.1\lib\netstandard2.0\NAudio.Midi.dll</HintPath>
</Reference>
<Reference Include="NAudio.Wasapi, Version=2.2.1.0, Culture=neutral, PublicKeyToken=e279aa5131008a41, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.Wasapi.2.2.1\lib\netstandard2.0\NAudio.Wasapi.dll</HintPath>
</Reference>
<Reference Include="NAudio.WinForms, Version=2.2.1.0, Culture=neutral, PublicKeyToken=e279aa5131008a41, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.WinForms.2.2.1\lib\net472\NAudio.WinForms.dll</HintPath>
</Reference>
<Reference Include="NAudio.WinMM, Version=2.2.1.0, Culture=neutral, PublicKeyToken=e279aa5131008a41, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.WinMM.2.2.1\lib\netstandard2.0\NAudio.WinMM.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.6.0.5\lib\net46\NLog.dll</HintPath>
</Reference>
<Reference Include="SocketIOClient, Version=4.0.0.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SocketIOClient.4.0.0.2\lib\netstandard2.0\SocketIOClient.dll</HintPath>
</Reference>
<Reference Include="SocketIOClient.Common, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SocketIOClient.Common.4.0.0\lib\netstandard2.0\SocketIOClient.Common.dll</HintPath>
</Reference>
<Reference Include="SocketIOClient.Serializer, Version=4.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SocketIOClient.Serializer.4.0.0.1\lib\netstandard2.0\SocketIOClient.Serializer.dll</HintPath>
</Reference>
<Reference Include="SocketIOClient.Serializer.NewtonsoftJson, Version=4.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SocketIOClient.Serializer.NewtonsoftJson.4.0.0.1\lib\netstandard2.0\SocketIOClient.Serializer.NewtonsoftJson.dll</HintPath>
</Reference>
<Reference Include="StreamDeckTools, Version=6.3.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\StreamDeck-Tools.6.3.2\lib\netstandard2.0\StreamDeckTools.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=10.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.10.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Drawing.Common.9.0.10\lib\net462\System.Drawing.Common.dll</HintPath>
</Reference>
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Pipelines, Version=10.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Pipelines.10.0.2\lib\net462\System.IO.Pipelines.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security.AccessControl, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.AccessControl.4.7.0\lib\net461\System.Security.AccessControl.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Principal.Windows, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Principal.Windows.4.7.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
</Reference>
<Reference Include="System.ServiceModel" />
<Reference Include="System.Text.Encodings.Web, Version=10.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.10.0.2\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=10.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.10.0.2\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BaseTest.cs" /> <None Update="DialLayout.json">
<Compile Include="Client\ClipMetadata.cs" />
<Compile Include="Client\ClipTrimClient.cs" />
<Compile Include="Client\CollectionMetaData.cs" />
<Compile Include="GlobalSettings.cs" />
<Compile Include="Player.cs" />
<Compile Include="ProfileSwitcher.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WavPlayer.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="DialLayout.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="manifest.json"> <None Update="manifest.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="!!README!!.txt" /> <Content Include="!!README!!.txt" />
@ -251,18 +92,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>npm run stop</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>npm run start</PostBuildEvent>
</PropertyGroup>
<Import Project="..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets" Condition="Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets'))" />
</Target>
</Project> </Project>

View File

@ -7,7 +7,6 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using BarRaider.SdTools.Wrappers; using BarRaider.SdTools.Wrappers;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using NAudio.MediaFoundation;
namespace ClipTrimDotNet namespace ClipTrimDotNet
{ {
@ -90,18 +89,18 @@ namespace ClipTrimDotNet
{ {
return new FileEntry(); return new FileEntry();
} }
Logger.Instance.LogMessage(TracingLevel.INFO, "fetched file settings " + filename + JsonConvert.SerializeObject(file)); //Logger.Instance.LogMessage(TracingLevel.INFO, "fetched file settings " + filename + JsonConvert.SerializeObject(file));
return file; return file;
} }
public void SetFileOptionsCurrentProfile(string filename, FileEntry file) public void SetFileOptionsCurrentProfile(string filename, FileEntry file)
{ {
Logger.Instance.LogMessage(TracingLevel.INFO, "SetFileOptionsCurrentProfile "); //Logger.Instance.LogMessage(TracingLevel.INFO, "SetFileOptionsCurrentProfile ");
if (!Collections.TryGetValue(ProfileName, out CollectionEntry collection)) if (!Collections.TryGetValue(ProfileName, out CollectionEntry collection))
{ {
return; return;
} }
Logger.Instance.LogMessage(TracingLevel.INFO, "SetFileOptionsCurrentProfile 2"); //Logger.Instance.LogMessage(TracingLevel.INFO, "SetFileOptionsCurrentProfile 2");
//collection.Files[filename] = file; //collection.Files[filename] = file;
Collections[ProfileName].Files[filename] = file; Collections[ProfileName].Files[filename] = file;
} }

View File

@ -1,8 +1,7 @@
using BarRaider.SdTools; using BarRaider.SdTools;
using BarRaider.SdTools.Wrappers; using BarRaider.SdTools.Wrappers;
using ClipTrimDotNet.Client; using ClipTrimDotNet.Client;
using NAudio.CoreAudioApi.Interfaces; using System.Text.Json.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -34,15 +33,15 @@ namespace ClipTrimDotNet
} }
[FilenameProperty] [FilenameProperty]
[JsonProperty(PropertyName = "path")] [JsonPropertyName("path")]
public string? Path { get; set; } public string? Path { get; set; }
[JsonProperty(PropertyName = "index")] [JsonPropertyName("index")]
public int? Index { get; set; } public int? Index { get; set; }
[JsonProperty(PropertyName = "playtype")] [JsonPropertyName("playtype")]
public string PlayType { get; set; } public string PlayType { get; set; }
[JsonProperty(PropertyName = "volume")] [JsonPropertyName("volume")]
public double Volume { get; set; } public double Volume { get; set; }
} }
@ -83,7 +82,8 @@ namespace ClipTrimDotNet
//if (settings == null || GlobalSettings.Instance.ProfileName ==null) return; //if (settings == null || GlobalSettings.Instance.ProfileName ==null) return;
metadata = ClipTrimClient.Instance.GetClipByPagedIndex(GetIndex()); metadata = ClipTrimClient.Instance.GetClipByPagedIndex(GetIndex());
await Connection.SetTitleAsync($"{metadata?.Name ?? ""}"); await Connection.SetTitleAsync($"{metadata?.Name ?? ""}");
//Logger.Instance.LogMessage(TracingLevel.INFO, $"Set title to {metadata?.Name ?? ""}");
return; return;
//var files = Directory.GetFiles(Path.Combine(Path.GetDirectoryName(GlobalSettings.Instance.BasePath), GlobalSettings.Instance.ProfileName), "*.wav", SearchOption.TopDirectoryOnly) //var files = Directory.GetFiles(Path.Combine(Path.GetDirectoryName(GlobalSettings.Instance.BasePath), GlobalSettings.Instance.ProfileName), "*.wav", SearchOption.TopDirectoryOnly)
@ -151,13 +151,14 @@ namespace ClipTrimDotNet
} }
public override void OnTick() { public override void OnTick() {
CheckFile(); CheckFile();
} }
public override async void ReceivedSettings(ReceivedSettingsPayload payload) public override async void ReceivedSettings(ReceivedSettingsPayload payload)
{ {
Logger.Instance.LogMessage(TracingLevel.INFO, "Player rec settings"); //Logger.Instance.LogMessage(TracingLevel.INFO, "Player rec settings");
Tools.AutoPopulateSettings(settings, payload.Settings); Tools.AutoPopulateSettings(settings, payload.Settings);
GlobalSettings.Instance.SetFileOptionsCurrentProfile(settings.Path, new FileEntry() { Playtype = settings.PlayType, Volume = settings.Volume }); GlobalSettings.Instance.SetFileOptionsCurrentProfile(settings.Path, new FileEntry() { Playtype = settings.PlayType, Volume = settings.Volume });
await Connection.SetGlobalSettingsAsync(JObject.FromObject(GlobalSettings.Instance)); await Connection.SetGlobalSettingsAsync(JObject.FromObject(GlobalSettings.Instance));

View File

@ -1,8 +1,6 @@
using BarRaider.SdTools; using BarRaider.SdTools;
using BarRaider.SdTools.Wrappers; using BarRaider.SdTools.Wrappers;
using ClipTrimDotNet.Client; using ClipTrimDotNet.Client;
using NAudio.CoreAudioApi.Interfaces;
using NAudio.Wave;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System; using System;
@ -61,7 +59,7 @@ namespace ClipTrimDotNet
private async void SetTitle() private async void SetTitle()
{ {
await Connection.SetTitleAsync(settings.ProfileName + " A"); await Connection.SetTitleAsync(settings.ProfileName + " B");
} }
private async void Connection_OnSendToPlugin(object sender, SDEventReceivedEventArgs<BarRaider.SdTools.Events.SendToPlugin> e) private async void Connection_OnSendToPlugin(object sender, SDEventReceivedEventArgs<BarRaider.SdTools.Events.SendToPlugin> e)
@ -79,21 +77,21 @@ namespace ClipTrimDotNet
//Logger.Instance.LogMessage(TracingLevel.INFO, "get profiles return " + JsonConvert.SerializeObject(obj)); //Logger.Instance.LogMessage(TracingLevel.INFO, "get profiles return " + JsonConvert.SerializeObject(obj));
await Connection.SendToPropertyInspectorAsync(obj); await Connection.SendToPropertyInspectorAsync(obj);
} }
if (e.Event.Payload["event"].ToString() == "getOutputDevices") //if (e.Event.Payload["event"].ToString() == "getOutputDevices")
{ //{
List<WaveOutCapabilities> devices = new List<WaveOutCapabilities>(); // List<WaveOutCapabilities> devices = new List<WaveOutCapabilities>();
for (int n = -1; n < WaveOut.DeviceCount; n++) // for (int n = -1; n < WaveOut.DeviceCount; n++)
{ // {
var caps = WaveOut.GetCapabilities(n); // var caps = WaveOut.GetCapabilities(n);
devices.Add(caps); // devices.Add(caps);
} // }
var items = devices.Select(x => new DataSourceItem { label = x.ProductName, value = x.ProductName }); // var items = devices.Select(x => new DataSourceItem { label = x.ProductName, value = x.ProductName });
var obj = new JObject(); // var obj = new JObject();
obj["event"] = "getOutputDevices"; // obj["event"] = "getOutputDevices";
obj["items"] = JArray.FromObject(items); // obj["items"] = JArray.FromObject(items);
//Logger.Instance.LogMessage(TracingLevel.INFO, "get devices return " + JsonConvert.SerializeObject(obj)); // //Logger.Instance.LogMessage(TracingLevel.INFO, "get devices return " + JsonConvert.SerializeObject(obj));
await Connection.SendToPropertyInspectorAsync(obj); // await Connection.SendToPropertyInspectorAsync(obj);
} //}
} }
@ -114,7 +112,7 @@ namespace ClipTrimDotNet
//Logger.Instance.LogMessage(TracingLevel.INFO, JsonConvert.SerializeObject(GlobalSettings.Instance)); //Logger.Instance.LogMessage(TracingLevel.INFO, JsonConvert.SerializeObject(GlobalSettings.Instance));
ClipTrimClient.Instance.SetSelectedCollectionByName(settings.ProfileName); ClipTrimClient.Instance.SetSelectedCollectionByName(settings.ProfileName);
GlobalSettings.Instance.SetCurrentProfile(settings.ProfileName); GlobalSettings.Instance.SetCurrentProfile(settings.ProfileName);
Logger.Instance.LogMessage(TracingLevel.INFO, JsonConvert.SerializeObject(GlobalSettings.Instance)); //Logger.Instance.LogMessage(TracingLevel.INFO, JsonConvert.SerializeObject(GlobalSettings.Instance));
await Connection.SetGlobalSettingsAsync(JObject.FromObject(GlobalSettings.Instance)); await Connection.SetGlobalSettingsAsync(JObject.FromObject(GlobalSettings.Instance));
await Connection.SwitchProfileAsync("ClipTrim"); await Connection.SwitchProfileAsync("ClipTrim");

View File

@ -13,6 +13,7 @@ namespace ClipTrimDotNet
{ {
// Uncomment this line of code to allow for debugging // Uncomment this line of code to allow for debugging
//while (!System.Diagnostics.Debugger.IsAttached) { System.Threading.Thread.Sleep(100); } //while (!System.Diagnostics.Debugger.IsAttached) { System.Threading.Thread.Sleep(100); }
Client.ClipTrimClient.Instance.PortNumber = 5010;
SDWrapper.Run(args); SDWrapper.Run(args);
} }
} }

View File

@ -1,16 +1,6 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ClipTrimDotNet")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClipTrimDotNet")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -21,16 +11,3 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM // The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1bb90885-9d98-46ef-b983-4a4ef3aea890")] [assembly: Guid("1bb90885-9d98-46ef-b983-4a4ef3aea890")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,225 +1,225 @@
using System; //using System;
using System.Collections.Concurrent; //using System.Collections.Concurrent;
using System.Collections.Generic; //using System.Collections.Generic;
using System.Linq; //using System.Linq;
using System.ServiceModel.Security; //using System.ServiceModel.Security;
using System.Threading.Tasks; //using System.Threading.Tasks;
using BarRaider.SdTools; //using BarRaider.SdTools;
using NAudio.Wave; //using NAudio.Wave;
using NAudio.Wave.SampleProviders; //using NAudio.Wave.SampleProviders;
using Newtonsoft.Json; //using Newtonsoft.Json;
class CachedSound //class CachedSound
{ //{
public byte[] AudioData { get; private set; } // public byte[] AudioData { get; private set; }
public WaveFormat WaveFormat { get; private set; } // public WaveFormat WaveFormat { get; private set; }
public CachedSound(string audioFileName) // public CachedSound(string audioFileName)
{ // {
using (var audioFileReader = new AudioFileReader(audioFileName)) // using (var audioFileReader = new AudioFileReader(audioFileName))
{ // {
// TODO: could add resampling in here if required // // TODO: could add resampling in here if required
WaveFormat = audioFileReader.WaveFormat; // WaveFormat = audioFileReader.WaveFormat;
var wholeFile = new List<byte>((int)(audioFileReader.Length)); // var wholeFile = new List<byte>((int)(audioFileReader.Length));
var readBuffer = new byte[audioFileReader.WaveFormat.SampleRate * audioFileReader.WaveFormat.Channels*4]; // var readBuffer = new byte[audioFileReader.WaveFormat.SampleRate * audioFileReader.WaveFormat.Channels*4];
int samplesRead; // int samplesRead;
while ((samplesRead = audioFileReader.Read(readBuffer, 0, readBuffer.Length)) > 0) // while ((samplesRead = audioFileReader.Read(readBuffer, 0, readBuffer.Length)) > 0)
{ // {
wholeFile.AddRange(readBuffer.Take(samplesRead)); // wholeFile.AddRange(readBuffer.Take(samplesRead));
} // }
AudioData = wholeFile.ToArray(); // AudioData = wholeFile.ToArray();
} // }
//Logger.Instance.LogMessage(TracingLevel.INFO, $"AudioData Length {AudioData.Length}"); // //Logger.Instance.LogMessage(TracingLevel.INFO, $"AudioData Length {AudioData.Length}");
} // }
} //}
class CachedSoundSampleProvider : IWaveProvider //class CachedSoundSampleProvider : IWaveProvider
{ //{
private readonly CachedSound cachedSound; // private readonly CachedSound cachedSound;
private long position; // private long position;
~CachedSoundSampleProvider() { // ~CachedSoundSampleProvider() {
//Logger.Instance.LogMessage(TracingLevel.INFO, $"Cache destructor"); // //Logger.Instance.LogMessage(TracingLevel.INFO, $"Cache destructor");
} // }
public CachedSoundSampleProvider(CachedSound cachedSound) // public CachedSoundSampleProvider(CachedSound cachedSound)
{ // {
this.cachedSound = cachedSound; // this.cachedSound = cachedSound;
position = 0; // position = 0;
} // }
public int Read(byte[] buffer, int offset, int count) // public int Read(byte[] buffer, int offset, int count)
{ // {
//Logger.Instance.LogMessage(TracingLevel.INFO, $"Read1 byte"); // //Logger.Instance.LogMessage(TracingLevel.INFO, $"Read1 byte");
var availableSamples = cachedSound.AudioData.Length - position; // var availableSamples = cachedSound.AudioData.Length - position;
var samplesToCopy = Math.Min(availableSamples, count); // var samplesToCopy = Math.Min(availableSamples, count);
try // try
{ // {
//Logger.Instance.LogMessage(TracingLevel.INFO, $"{cachedSound.AudioData.GetType()} {buffer.GetType()}"); // //Logger.Instance.LogMessage(TracingLevel.INFO, $"{cachedSound.AudioData.GetType()} {buffer.GetType()}");
Array.Copy(cachedSound.AudioData, position, buffer, offset, samplesToCopy); // Array.Copy(cachedSound.AudioData, position, buffer, offset, samplesToCopy);
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
//Logger.Instance.LogMessage(TracingLevel.INFO, $"{ex.ToString()}"); // //Logger.Instance.LogMessage(TracingLevel.INFO, $"{ex.ToString()}");
} // }
//Logger.Instance.LogMessage(TracingLevel.INFO, $"Read3"); // //Logger.Instance.LogMessage(TracingLevel.INFO, $"Read3");
position += samplesToCopy; // position += samplesToCopy;
//Logger.Instance.LogMessage(TracingLevel.INFO, $"Sending {samplesToCopy} samples"); // //Logger.Instance.LogMessage(TracingLevel.INFO, $"Sending {samplesToCopy} samples");
return (int)samplesToCopy; // return (int)samplesToCopy;
} // }
public WaveFormat WaveFormat => cachedSound.WaveFormat; // public WaveFormat WaveFormat => cachedSound.WaveFormat;
} //}
public class WavPlayer //public class WavPlayer
{ //{
private static WavPlayer? instance; // private static WavPlayer? instance;
public static WavPlayer Instance // public static WavPlayer Instance
{ // {
get // get
{ // {
instance ??= new WavPlayer(); // instance ??= new WavPlayer();
return instance; // return instance;
} // }
} // }
public enum PlayMode // public enum PlayMode
{ // {
PlayOverlap, // PlayOverlap,
PlayStop // PlayStop
} // }
private readonly ConcurrentDictionary<string, List<Tuple<WaveOutEvent, IWaveProvider>>> _activePlayers; // private readonly ConcurrentDictionary<string, List<Tuple<WaveOutEvent, IWaveProvider>>> _activePlayers;
public WavPlayer() // public WavPlayer()
{ // {
_activePlayers = new ConcurrentDictionary<string, List<Tuple<WaveOutEvent, IWaveProvider>>>(); // _activePlayers = new ConcurrentDictionary<string, List<Tuple<WaveOutEvent, IWaveProvider>>>();
} // }
public void Play(string filePath, string id, double volume, PlayMode mode) // public void Play(string filePath, string id, double volume, PlayMode mode)
{ // {
if (string.IsNullOrWhiteSpace(filePath)) // if (string.IsNullOrWhiteSpace(filePath))
throw new ArgumentException("File path cannot be null or empty.", nameof(filePath)); // throw new ArgumentException("File path cannot be null or empty.", nameof(filePath));
if (mode == PlayMode.PlayOverlap) // if (mode == PlayMode.PlayOverlap)
{ // {
PlayWithOverlap(filePath, id, volume); // PlayWithOverlap(filePath, id, volume);
} // }
else if (mode == PlayMode.PlayStop) // else if (mode == PlayMode.PlayStop)
{ // {
PlayWithStop(filePath, id, volume); // PlayWithStop(filePath, id, volume);
} // }
else // else
{ // {
throw new ArgumentOutOfRangeException(nameof(mode), "Invalid play mode specified."); // throw new ArgumentOutOfRangeException(nameof(mode), "Invalid play mode specified.");
} // }
} // }
private void PlayWithOverlap(string filePath, string id, double volume) // private void PlayWithOverlap(string filePath, string id, double volume)
{ // {
try // try
{ // {
//Logger.Instance.LogMessage(TracingLevel.INFO, "Play overlap"); // //Logger.Instance.LogMessage(TracingLevel.INFO, "Play overlap");
var player = CreatePlayer(filePath, id); // var player = CreatePlayer(filePath, id);
if (!_activePlayers.ContainsKey(filePath)) // if (!_activePlayers.ContainsKey(filePath))
{ // {
_activePlayers[filePath] = new List<Tuple<WaveOutEvent, IWaveProvider>>(); // _activePlayers[filePath] = new List<Tuple<WaveOutEvent, IWaveProvider>>();
} // }
_activePlayers[filePath].Add(player); // _activePlayers[filePath].Add(player);
player.Item1.Volume = (float)volume; // player.Item1.Volume = (float)volume;
player.Item1.Play(); // player.Item1.Play();
} // }
catch(Exception ex) // catch(Exception ex)
{ // {
//Logger.Instance.LogMessage(TracingLevel.INFO, ex.ToString()); // //Logger.Instance.LogMessage(TracingLevel.INFO, ex.ToString());
} // }
//var playersToDispose = _activePlayers[filePath].Where(x => x.Item1.PlaybackState == PlaybackState.Stopped).ToList(); // //var playersToDispose = _activePlayers[filePath].Where(x => x.Item1.PlaybackState == PlaybackState.Stopped).ToList();
//foreach (var p in playersToDispose) // //foreach (var p in playersToDispose)
//{ // //{
// p.Item1.Stop(); // // p.Item1.Stop();
// p.Item1.Dispose(); // // p.Item1.Dispose();
//} // //}
//_activePlayers[filePath].RemoveAll(x => x.Item1.PlaybackState == PlaybackState.Stopped); // //_activePlayers[filePath].RemoveAll(x => x.Item1.PlaybackState == PlaybackState.Stopped);
} // }
private void PlayWithStop(string filePath, string id, double volume) // private void PlayWithStop(string filePath, string id, double volume)
{ // {
if (_activePlayers.TryGetValue(filePath, out var players)) // if (_activePlayers.TryGetValue(filePath, out var players))
{ // {
// Stop and dispose all current players for this file // // Stop and dispose all current players for this file
if (players.Any(x => x.Item1.PlaybackState == PlaybackState.Playing)) // if (players.Any(x => x.Item1.PlaybackState == PlaybackState.Playing))
{ // {
var playersToDispose = players.ToList(); // var playersToDispose = players.ToList();
foreach (var player in playersToDispose) // foreach (var player in playersToDispose)
{ // {
player.Item1.Stop(); // player.Item1.Stop();
player.Item1.Dispose(); // player.Item1.Dispose();
} // }
} // }
else // else
{ // {
PlayWithOverlap(filePath, id, volume); // PlayWithOverlap(filePath, id, volume);
} // }
} // }
else // else
{ // {
// Start a new player // // Start a new player
PlayWithOverlap(filePath, id, volume); // PlayWithOverlap(filePath, id, volume);
} // }
_activePlayers[filePath].RemoveAll(x => x.Item1.PlaybackState == PlaybackState.Stopped); // _activePlayers[filePath].RemoveAll(x => x.Item1.PlaybackState == PlaybackState.Stopped);
} // }
private Tuple<WaveOutEvent, IWaveProvider> CreatePlayer(string filePath, string name) // private Tuple<WaveOutEvent, IWaveProvider> CreatePlayer(string filePath, string name)
{ // {
var reader = new CachedSoundSampleProvider(new CachedSound(filePath)); // var reader = new CachedSoundSampleProvider(new CachedSound(filePath));
//var reader = new AudioFileReader(filePath); // //var reader = new AudioFileReader(filePath);
int number = -1; // int number = -1;
for (int i = 0; i < WaveOut.DeviceCount; ++i) // for (int i = 0; i < WaveOut.DeviceCount; ++i)
{ // {
if (WaveOut.GetCapabilities(i).ProductName == name) // if (WaveOut.GetCapabilities(i).ProductName == name)
{ // {
number = i; // number = i;
} // }
} // }
var player = new WaveOutEvent() { DeviceNumber = number }; // var player = new WaveOutEvent() { DeviceNumber = number };
player.Init(reader); // player.Init(reader);
return new Tuple<WaveOutEvent, IWaveProvider>(player, reader); // return new Tuple<WaveOutEvent, IWaveProvider>(player, reader);
} // }
private void CleanupPlayer(string filePath) // private void CleanupPlayer(string filePath)
{ // {
if (_activePlayers.TryGetValue(filePath, out var players)) // if (_activePlayers.TryGetValue(filePath, out var players))
{ // {
var playersToDispose = players.ToList(); // var playersToDispose = players.ToList();
foreach (var p in playersToDispose) // foreach (var p in playersToDispose)
{ // {
p.Item1.Stop(); // p.Item1.Stop();
p.Item1.Dispose(); // p.Item1.Dispose();
} // }
} // }
_activePlayers[filePath].RemoveAll(x => x.Item1.PlaybackState == PlaybackState.Stopped); // _activePlayers[filePath].RemoveAll(x => x.Item1.PlaybackState == PlaybackState.Stopped);
} // }
public void StopAll() // public void StopAll()
{ // {
foreach (var players in _activePlayers.Values) // foreach (var players in _activePlayers.Values)
{ // {
var playersToDispose = players.ToList(); // var playersToDispose = players.ToList();
foreach (var player in playersToDispose) // foreach (var player in playersToDispose)
{ // {
player.Item1.Stop(); // player.Item1.Stop();
player.Item1.Dispose(); // player.Item1.Dispose();
} // }
players.Clear(); // players.Clear();
} // }
_activePlayers.Clear(); // _activePlayers.Clear();
} // }
} //}

View File

@ -1,12 +1,12 @@
{ {
"scripts": { "scripts": {
"stop": "streamdeck stop com.michal-courson.cliptrim", "stop": "streamdeck stop com.michal-courson.cliptrim",
"copy": "@powershell robocopy bin/Debug/ClipTrimDotNet.sdPlugin bin/Debug/com.michal-courson.cliptrim.sdPlugin", "copy": "@powershell robocopy bin/Debug/ClipTrimDotNet.sdPlugin bin/Debug/com.michal-courson.cliptrim.sdPlugin/net8.0-windows",
"link": "streamdeck link bin/Debug/com.michal-courson.cliptrim.sdPlugin", "link": "streamdeck link bin/Debug/com.michal-courson.cliptrim.sdPlugin",
"restart": "streamdeck restart com.michal-courson.cliptrim", "restart": "streamdeck restart com.michal-courson.cliptrim",
"start": "npm run link && npm run restart", "start": "npm run link && npm run restart",
"all": "npm run stop && npm run copy && npm run link && npm run restart", "all": "npm run stop && npm run copy && npm run link && npm run restart",
"pack": "streamdeck pack bin/Debug/com.michal-courson.cliptrim.sdPlugin/" "pack": "streamdeck pack bin/Debug/com.michal-courson.cliptrim.sdPlugin/net8.0-windows/"
}, },
"devDependencies": { "devDependencies": {
"shx": "^0.3.4" "shx": "^0.3.4"