protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments) { if (this.ActionType == StreamingActionTypeEnum.TextSource && !string.IsNullOrEmpty(this.SourceText)) { this.UpdateReferenceTextFile(await this.ReplaceStringWithSpecialModifiers(this.SourceText, user, arguments)); } string url = string.Empty; if (this.ActionType == StreamingActionTypeEnum.WebBrowserSource && !string.IsNullOrEmpty(this.SourceURL)) { url = await this.ReplaceStringWithSpecialModifiers(this.SourceURL, user, arguments); } IStreamingSoftwareService ssService = null; if (this.SelectedStreamingSoftware == StreamingSoftwareTypeEnum.OBSStudio) { if (ChannelSession.Services.OBSWebsocket == null) { await ChannelSession.Services.InitializeOBSWebsocket(); } ssService = ChannelSession.Services.OBSWebsocket; } else if (this.SelectedStreamingSoftware == StreamingSoftwareTypeEnum.XSplit) { if (ChannelSession.Services.XSplitServer == null) { await ChannelSession.Services.InitializeXSplitServer(); } ssService = ChannelSession.Services.XSplitServer; } else if (this.SelectedStreamingSoftware == StreamingSoftwareTypeEnum.StreamlabsOBS) { if (ChannelSession.Services.StreamlabsOBSService == null) { await ChannelSession.Services.InitializeStreamlabsOBSService(); } ssService = ChannelSession.Services.StreamlabsOBSService; } if (ssService != null) { if (this.ActionType == StreamingActionTypeEnum.StartStopStream) { await ssService.StartStopStream(); } else if (this.ActionType == StreamingActionTypeEnum.SaveReplayBuffer) { await ssService.SaveReplayBuffer(); } else if (this.ActionType == StreamingActionTypeEnum.Scene && !string.IsNullOrEmpty(this.SceneName)) { await ssService.ShowScene(this.SceneName); } else if (!string.IsNullOrEmpty(this.SourceName)) { if (this.ActionType == StreamingActionTypeEnum.WebBrowserSource && !string.IsNullOrEmpty(this.SourceURL)) { await ssService.SetWebBrowserSourceURL(this.SceneName, this.SourceName, url); } else if (this.ActionType == StreamingActionTypeEnum.SourceDimensions && this.SourceDimensions != null) { await ssService.SetSourceDimensions(this.SceneName, this.SourceName, this.SourceDimensions); } await ssService.SetSourceVisibility(this.SceneName, this.SourceName, this.SourceVisible); } } }
protected override async Task PerformInternal(CommandParametersModel parameters) { IStreamingSoftwareService ssService = null; if (this.SelectedStreamingSoftware == StreamingSoftwareTypeEnum.OBSStudio) { ssService = ChannelSession.Services.OBSStudio; } else if (this.SelectedStreamingSoftware == StreamingSoftwareTypeEnum.XSplit) { ssService = ChannelSession.Services.XSplit; } else if (this.SelectedStreamingSoftware == StreamingSoftwareTypeEnum.StreamlabsOBS) { ssService = ChannelSession.Services.StreamlabsOBS; } if (ssService != null && ssService.IsEnabled) { Logger.Log(LogLevel.Debug, "Checking for Streaming Software connection"); if (!ssService.IsConnected) { Result result = await ssService.Connect(); if (!result.Success) { Logger.Log(LogLevel.Error, result.Message); return; } } Logger.Log(LogLevel.Debug, "Performing for Streaming Software connection"); if (ssService.IsConnected) { string name = null; if (!string.IsNullOrEmpty(this.ItemName)) { name = await ReplaceStringWithSpecialModifiers(this.ItemName, parameters); } string parentName = null; if (!string.IsNullOrEmpty(this.ParentName)) { parentName = await ReplaceStringWithSpecialModifiers(this.ParentName, parameters); } if (this.ActionType == StreamingSoftwareActionTypeEnum.StartStopStream) { await ssService.StartStopStream(); } else if (this.ActionType == StreamingSoftwareActionTypeEnum.StartStopRecording) { await ssService.StartStopRecording(); } else if (this.ActionType == StreamingSoftwareActionTypeEnum.SaveReplayBuffer) { await ssService.SaveReplayBuffer(); } else if (this.ActionType == StreamingSoftwareActionTypeEnum.Scene) { if (!string.IsNullOrEmpty(name)) { await ssService.ShowScene(name); } } else if (this.ActionType == StreamingSoftwareActionTypeEnum.SourceFilterVisibility) { if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(parentName)) { await ssService.SetSourceFilterVisibility(parentName, name, this.Visible); } } else if (!string.IsNullOrEmpty(name)) { if (this.ActionType == StreamingSoftwareActionTypeEnum.WebBrowserSource && !string.IsNullOrEmpty(this.SourceURL)) { await ssService.SetWebBrowserSourceURL(parentName, name, await ReplaceStringWithSpecialModifiers(this.SourceURL, parameters)); } else if (this.ActionType == StreamingSoftwareActionTypeEnum.TextSource && !string.IsNullOrEmpty(this.SourceText) && !string.IsNullOrEmpty(this.SourceTextFilePath)) { try { if (!Directory.Exists(Path.GetDirectoryName(this.SourceTextFilePath))) { Directory.CreateDirectory(Path.GetDirectoryName(this.SourceTextFilePath)); } using (StreamWriter writer = new StreamWriter(File.Open(this.SourceTextFilePath, FileMode.Create))) { writer.Write(await ReplaceStringWithSpecialModifiers(this.SourceText, parameters)); writer.Flush(); } } catch (Exception ex) { Logger.Log(ex); } } else if (this.ActionType == StreamingSoftwareActionTypeEnum.SourceDimensions && this.SourceDimensions != null) { await ssService.SetSourceDimensions(parentName, name, this.SourceDimensions); } await ssService.SetSourceVisibility(parentName, name, this.Visible); } else if (this.ActionType == StreamingSoftwareActionTypeEnum.SceneCollection && !string.IsNullOrEmpty(name)) { await ssService.SetSceneCollection(name); } } } else { Logger.Log(LogLevel.Error, "The Streaming Software selected is not enabled: " + this.SelectedStreamingSoftware); } }
protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments) { if (this.ActionType == StreamingActionTypeEnum.TextSource && !string.IsNullOrEmpty(this.SourceText)) { this.UpdateReferenceTextFile(await this.ReplaceStringWithSpecialModifiers(this.SourceText, user, arguments)); } string url = string.Empty; if (this.ActionType == StreamingActionTypeEnum.WebBrowserSource && !string.IsNullOrEmpty(this.SourceURL)) { url = await this.ReplaceStringWithSpecialModifiers(this.SourceURL, user, arguments); } string sceneName = null; if (!string.IsNullOrEmpty(this.SceneName)) { sceneName = await this.ReplaceStringWithSpecialModifiers(this.SceneName, user, arguments); } string sourceName = null; if (!string.IsNullOrEmpty(this.SourceName)) { sourceName = await this.ReplaceStringWithSpecialModifiers(this.SourceName, user, arguments); } IStreamingSoftwareService ssService = null; if (this.SelectedStreamingSoftware == StreamingSoftwareTypeEnum.OBSStudio) { ssService = ChannelSession.Services.OBSStudio; } else if (this.SelectedStreamingSoftware == StreamingSoftwareTypeEnum.XSplit) { ssService = ChannelSession.Services.XSplit; } else if (this.SelectedStreamingSoftware == StreamingSoftwareTypeEnum.StreamlabsOBS) { ssService = ChannelSession.Services.StreamlabsOBS; } if (ssService != null && ssService.IsEnabled) { Logger.Log(LogLevel.Debug, "Checking for Streaming Software connection"); if (!ssService.IsConnected) { Result result = await ssService.Connect(); if (!result.Success) { Logger.Log(LogLevel.Error, result.Message); return; } } Logger.Log(LogLevel.Debug, "Performing for Streaming Software connection"); if (ssService.IsConnected) { if (this.ActionType == StreamingActionTypeEnum.StartStopStream) { await ssService.StartStopStream(); } else if (this.ActionType == StreamingActionTypeEnum.SaveReplayBuffer) { await ssService.SaveReplayBuffer(); } else if (this.ActionType == StreamingActionTypeEnum.Scene && !string.IsNullOrEmpty(sceneName)) { await ssService.ShowScene(sceneName); } else if (!string.IsNullOrEmpty(sourceName)) { if (this.ActionType == StreamingActionTypeEnum.WebBrowserSource && !string.IsNullOrEmpty(this.SourceURL)) { await ssService.SetWebBrowserSourceURL(sceneName, sourceName, url); } else if (this.ActionType == StreamingActionTypeEnum.SourceDimensions && this.SourceDimensions != null) { await ssService.SetSourceDimensions(sceneName, sourceName, this.SourceDimensions); } await ssService.SetSourceVisibility(sceneName, sourceName, this.SourceVisible); } else if (this.ActionType == StreamingActionTypeEnum.SceneCollection && !string.IsNullOrEmpty(this.SceneCollectionName)) { await ssService.SetSceneCollection(this.SceneCollectionName); } } } else { Logger.Log(LogLevel.Error, "The Streaming Software selected is not enabled: " + this.SelectedStreamingSoftware); } }