port selection on plugin
This commit is contained in:
@ -8,6 +8,18 @@
|
||||
"name": "Clip 20260226_195932",
|
||||
"playbackType": "playOverlap",
|
||||
"volume": 1
|
||||
},
|
||||
{
|
||||
"filename": "C:\\Users\\mickl\\Desktop\\cliptrim-ui\\ClipTrimApp\\audio-service\\recordings\\audio_capture_20260228_165611.wav",
|
||||
"name": "Clip 20260228_165611",
|
||||
"playbackType": "playStop",
|
||||
"volume": 1.0
|
||||
},
|
||||
{
|
||||
"filename": "C:\\Users\\mickl\\Desktop\\cliptrim-ui\\ClipTrimApp\\audio-service\\recordings\\audio_capture_20260228_165646.wav",
|
||||
"name": "Clip 20260228_165646",
|
||||
"playbackType": "playStop",
|
||||
"volume": 1.0
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -16,14 +28,14 @@
|
||||
"id": 1,
|
||||
"clips": [
|
||||
{
|
||||
"filename": "C:\\Users\\mickl\\Desktop\\cliptrim-ui\\ClipTrimApp\\audio-service\\recordings\\audio_capture_20260226_183607.wav",
|
||||
"name": "Clip 20260226_183607",
|
||||
"filename": "C:\\Users\\mickl\\Desktop\\cliptrim-ui\\ClipTrimApp\\audio-service\\recordings\\audio_capture_20260226_183812.wav",
|
||||
"name": "Clip 20260226_183812",
|
||||
"playbackType": "playStop",
|
||||
"volume": 1
|
||||
},
|
||||
{
|
||||
"filename": "C:\\Users\\mickl\\Desktop\\cliptrim-ui\\ClipTrimApp\\audio-service\\recordings\\audio_capture_20260226_183812.wav",
|
||||
"name": "Clip 20260226_183812",
|
||||
"filename": "C:\\Users\\mickl\\Desktop\\cliptrim-ui\\ClipTrimApp\\audio-service\\recordings\\audio_capture_20260226_183607.wav",
|
||||
"name": "Clip 20260226_183607",
|
||||
"playbackType": "playStop",
|
||||
"volume": 1
|
||||
},
|
||||
@ -79,7 +91,9 @@
|
||||
"filename": "C:\\Users\\mickl\\Desktop\\cliptrim-ui\\ClipTrimApp\\audio-service\\recordings\\audio_capture_20260228_092721.wav",
|
||||
"name": "Clip 20260228_092721",
|
||||
"playbackType": "playStop",
|
||||
"volume": 1
|
||||
"volume": 1,
|
||||
"startTime": 6.438382145377559,
|
||||
"endTime": 14.277258292166426
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -108,6 +122,12 @@
|
||||
"name": "pp",
|
||||
"playbackType": "playStop",
|
||||
"volume": 1
|
||||
},
|
||||
{
|
||||
"filename": "C:\\Users\\mickl\\Desktop\\cliptrim-ui\\ClipTrimApp\\audio-service\\recordings\\audio_capture_20260228_120955.wav",
|
||||
"name": "nose",
|
||||
"playbackType": "playStop",
|
||||
"volume": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -30,20 +30,26 @@ namespace ClipTrimDotNet.Client
|
||||
}
|
||||
|
||||
//private HttpClient httpClient;
|
||||
private SocketIO socket;
|
||||
private SocketIO? socket;
|
||||
|
||||
public int PortNumber { get; set; } = 5010;
|
||||
|
||||
public ClipTrimClient()
|
||||
public string HostName
|
||||
{
|
||||
//httpClient = new HttpClient()
|
||||
//{
|
||||
// BaseAddress = new Uri("http://localhost:5010/"),
|
||||
// Timeout = TimeSpan.FromSeconds(10)
|
||||
//};
|
||||
Logger.Instance.LogMessage(TracingLevel.INFO, $"Starting ClipTrimClient on port {PortNumber}");
|
||||
socket = new SocketIO(new Uri($"http://localhost:5010/"));
|
||||
get
|
||||
{
|
||||
//return $"http://localhost:5010/";
|
||||
return $"http://localhost:{GlobalSettings.Instance.PortNumber}/";
|
||||
}
|
||||
}
|
||||
|
||||
private string? currentHostname = null;
|
||||
|
||||
void CreateSocket()
|
||||
{
|
||||
Logger.Instance.LogMessage(TracingLevel.INFO, $"Starting ClipTrimClient on port {HostName}");
|
||||
socket = new SocketIO(new Uri(HostName));
|
||||
currentHostname = HostName;
|
||||
socket.Options.AutoUpgrade = false;
|
||||
//socket.Options.Path = "/socket.io";
|
||||
socket.Options.ConnectionTimeout = TimeSpan.FromSeconds(10);
|
||||
socket.Options.Reconnection = true;
|
||||
socket.On("full_data", ctx =>
|
||||
@ -85,6 +91,11 @@ namespace ClipTrimDotNet.Client
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
|
||||
socket.OnConnected += (sender, e) =>
|
||||
{
|
||||
Logger.Instance.LogMessage(TracingLevel.INFO, $"Socket connected: {e}");
|
||||
};
|
||||
|
||||
socket.OnDisconnected += (sender, e) =>
|
||||
{
|
||||
Logger.Instance.LogMessage(TracingLevel.INFO, $"Socket disconnected: {e}");
|
||||
@ -93,8 +104,19 @@ namespace ClipTrimDotNet.Client
|
||||
Task.Run(async () => await Connect());
|
||||
}
|
||||
|
||||
public ClipTrimClient()
|
||||
{
|
||||
//httpClient = new HttpClient()
|
||||
//{
|
||||
// BaseAddress = new Uri("http://localhost:5010/"),
|
||||
// Timeout = TimeSpan.FromSeconds(10)
|
||||
//};
|
||||
CreateSocket();
|
||||
}
|
||||
|
||||
public async Task Connect()
|
||||
{
|
||||
if (socket is null) return;
|
||||
while (!socket.Connected)
|
||||
{
|
||||
try
|
||||
@ -180,6 +202,12 @@ namespace ClipTrimDotNet.Client
|
||||
return Collections.Where(x => x.Name != "Uncategorized").Select(x => x.Name).ToList();
|
||||
}
|
||||
|
||||
public string GetCurrentCollectionName()
|
||||
{
|
||||
if (SelectedCollection == -1) return "";
|
||||
return Collections[SelectedCollection].Name;
|
||||
}
|
||||
|
||||
public string GetPlayerStringByCoordinateIndex(int index)
|
||||
{
|
||||
if (PageMode)
|
||||
@ -225,9 +253,10 @@ namespace ClipTrimDotNet.Client
|
||||
}
|
||||
else
|
||||
{
|
||||
if (socket is null) return;
|
||||
var metadata = GetClipByPagedIndex(index);
|
||||
if (metadata == null) return;
|
||||
Logger.Instance.LogMessage(TracingLevel.INFO, $"playing clip:");
|
||||
//Logger.Instance.LogMessage(TracingLevel.INFO, $"playing clip:");
|
||||
await socket.EmitAsync("play_clip", new List<object>() { metadata });
|
||||
}
|
||||
|
||||
@ -235,7 +264,24 @@ namespace ClipTrimDotNet.Client
|
||||
|
||||
public async void SaveClip()
|
||||
{
|
||||
if (socket is null) return;
|
||||
await socket.EmitAsync("record_clip", new List<object>() { });
|
||||
}
|
||||
|
||||
public async void CheckPort()
|
||||
{
|
||||
if (socket is null) return;
|
||||
//Logger.Instance.LogMessage(TracingLevel.INFO, $"Checking port {socket}");
|
||||
if (currentHostname != HostName)
|
||||
{
|
||||
//Logger.Instance.LogMessage(TracingLevel.INFO, $"port {socket}");
|
||||
if (socket.Connected)
|
||||
{
|
||||
await socket.DisconnectAsync();
|
||||
}
|
||||
socket.Dispose();
|
||||
CreateSocket();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ namespace ClipTrimDotNet
|
||||
{
|
||||
GlobalSettings instance = new GlobalSettings();
|
||||
instance.ProfileName = null;
|
||||
instance.PortNumber = 5010;
|
||||
return instance;
|
||||
}
|
||||
|
||||
@ -36,6 +37,9 @@ namespace ClipTrimDotNet
|
||||
[JsonProperty(PropertyName = "profileName")]
|
||||
public string? ProfileName { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "portNumber")]
|
||||
public int? PortNumber { get; set; }
|
||||
|
||||
|
||||
public void SetCurrentProfile(string profile)
|
||||
{
|
||||
|
||||
@ -68,7 +68,7 @@ namespace ClipTrimDotNet.Keys
|
||||
await Connection.SetTitleAsync(ClipTrimClient.Instance.CanPageDown ? "<" : "");
|
||||
break;
|
||||
case 1:
|
||||
await Connection.SetTitleAsync((ClipTrimClient.Instance.PageIndex + 1).ToString());
|
||||
await Connection.SetTitleAsync(ClipTrimClient.Instance.GetCurrentCollectionName() + "\n" + (ClipTrimClient.Instance.PageIndex + 1).ToString());
|
||||
break;
|
||||
case 2:
|
||||
await Connection.SetTitleAsync(ClipTrimClient.Instance.CanPageUp ? ">" : "");
|
||||
|
||||
@ -90,6 +90,8 @@ namespace ClipTrimDotNet.Keys
|
||||
public override async void KeyPressed(KeyPayload payload)
|
||||
{
|
||||
GlobalSettings.Instance.SetCurrentProfile(settings.ProfileName??"");
|
||||
ClipTrimClient.Instance.PageMode = false;
|
||||
PageNavigator.TickAll();
|
||||
|
||||
await Connection.SetGlobalSettingsAsync(JObject.FromObject(GlobalSettings.Instance));
|
||||
await Connection.SwitchProfileAsync("ClipTrim");
|
||||
@ -107,6 +109,7 @@ namespace ClipTrimDotNet.Keys
|
||||
|
||||
public override void ReceivedSettings(ReceivedSettingsPayload payload)
|
||||
{
|
||||
//Logger.Instance.LogMessage(TracingLevel.INFO, $"ProfileSwitcher received settings {JsonConvert.SerializeObject(payload.Settings)}");
|
||||
Tools.AutoPopulateSettings(settings, payload.Settings);
|
||||
SaveSettings();
|
||||
}
|
||||
@ -114,6 +117,7 @@ namespace ClipTrimDotNet.Keys
|
||||
public override void ReceivedGlobalSettings(ReceivedGlobalSettingsPayload payload)
|
||||
{
|
||||
Tools.AutoPopulateSettings(GlobalSettings.Instance, payload.Settings);
|
||||
ClipTrimClient.Instance.CheckPort();
|
||||
//if (payload.Settings == null || payload.Settings.Count == 0)
|
||||
//{
|
||||
// var inst = GlobalSettings.Instance;
|
||||
|
||||
@ -13,7 +13,7 @@ namespace ClipTrimDotNet
|
||||
{
|
||||
// Uncomment this line of code to allow for debugging
|
||||
//while (!System.Diagnostics.Debugger.IsAttached) { System.Threading.Thread.Sleep(100); }
|
||||
Client.ClipTrimClient.Instance.PortNumber = 5010;
|
||||
//Client.ClipTrimClient.Instance.PortNumber = 5010;
|
||||
SDWrapper.Run(args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,13 @@
|
||||
show-refresh="true"
|
||||
placeholder="Select a ClipTrim page"></sdpi-select>
|
||||
</sdpi-item>
|
||||
<sdpi-item>
|
||||
<sdpi-textfield
|
||||
global="true"
|
||||
setting="portNumber"
|
||||
placeholder="Port Number"
|
||||
pattern="[0-9]+"></sdpi-textfield>
|
||||
</sdpi-item>
|
||||
<!--<sdpi-item label="Base Path">
|
||||
<sdpi-file setting="basePath"
|
||||
global="true"
|
||||
|
||||
Reference in New Issue
Block a user