protected override async Task PerformInternal(CommandParametersModel parameters) { if (this.WidgetID != Guid.Empty) { OverlayWidgetModel widget = ChannelSession.Settings.OverlayWidgets.FirstOrDefault(w => w.Item.ID.Equals(this.WidgetID)); if (widget != null) { if (this.ShowWidget) { await widget.Enable(parameters); } else { await widget.Disable(); } } } else { string overlayName = (string.IsNullOrEmpty(this.OverlayName)) ? ChannelSession.Services.Overlay.DefaultOverlayName : this.OverlayName; IOverlayEndpointService overlay = ChannelSession.Services.Overlay.GetOverlay(overlayName); if (overlay != null) { await overlay.ShowItem(this.OverlayItem, parameters); } } }
protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments) { if (this.WidgetID != Guid.Empty) { OverlayWidgetModel widget = ChannelSession.Settings.OverlayWidgets.FirstOrDefault(w => w.Item.ID.Equals(this.WidgetID)); if (widget != null) { if (this.ShowWidget) { await widget.Enable(user, arguments, this.extraSpecialIdentifiers); } else { await widget.Disable(); } } } else { string overlayName = (string.IsNullOrEmpty(this.OverlayName)) ? ChannelSession.Services.Overlay.DefaultOverlayName : this.OverlayName; IOverlayEndpointService overlay = ChannelSession.Services.Overlay.GetOverlay(overlayName); if (overlay != null) { await overlay.ShowItem(this.OverlayItem, user, arguments, this.extraSpecialIdentifiers, this.platform); } } }
private async void Overlay_OnWebSocketConnectedOccurred(object sender, EventArgs e) { IOverlayEndpointService overlay = (IOverlayEndpointService)sender; this.OnOverlayConnectedOccurred(overlay, new EventArgs()); Logger.Log("Client connected to Overlay Endpoint - " + overlay.Name); overlay.StartBatching(); foreach (OverlayWidgetModel widget in ChannelSession.Settings.OverlayWidgets.Where(ow => ow.OverlayName.Equals(overlay.Name))) { try { if (widget.IsEnabled) { await widget.ShowItem(); await widget.LoadCachedData(); await widget.UpdateItem(); } } catch (Exception ex) { Logger.Log(ex); } } await overlay.EndBatching(); }
private void Overlay_OnWebSocketDisconnectedOccurred(object sender, WebSocketCloseStatus closeStatus) { IOverlayEndpointService overlay = (IOverlayEndpointService)sender; this.OnOverlayDisconnectedOccurred(overlay, closeStatus); Logger.Log("Client disconnect from Overlay Endpoint - " + overlay.Name); }
public async Task HideItem() { IOverlayEndpointService overlay = this.GetOverlay(); if (overlay != null) { await overlay.HideItem(this.Item); } }
public async Task UpdateItem(CommandParametersModel parameters) { IOverlayEndpointService overlay = this.GetOverlay(); if (overlay != null) { await overlay.UpdateItem(this.Item, parameters); } }
public async Task UpdateItem(UserViewModel user, IEnumerable <string> arguments, Dictionary <string, string> extraSpecialIdentifiers, StreamingPlatformTypeEnum platform) { IOverlayEndpointService overlay = this.GetOverlay(); if (overlay != null) { await overlay.UpdateItem(this.Item, user, arguments, extraSpecialIdentifiers, platform); } }
public async Task RemoveOverlay(string name) { IOverlayEndpointService overlay = this.GetOverlay(name); if (overlay != null) { overlay.OnWebSocketConnectedOccurred -= Overlay_OnWebSocketConnectedOccurred; overlay.OnWebSocketDisconnectedOccurred -= Overlay_OnWebSocketDisconnectedOccurred; await overlay.Disconnect(); this.overlays.Remove(name); } }
protected override async Task PerformInternal(CommandParametersModel parameters) { IOverlayEndpointService overlay = ChannelSession.Services.Overlay.GetOverlay(ChannelSession.Services.Overlay.DefaultOverlayName); if (overlay != null) { string message = await ReplaceStringWithSpecialModifiers(this.Text, parameters); await overlay.SendTextToSpeech(new OverlayTextToSpeech() { Text = message, Voice = this.Voice, Volume = this.Volume / 100.0, Pitch = this.Pitch / 100.0, Rate = this.Rate / 100.0 }); } }
protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments) { IOverlayEndpointService overlay = ChannelSession.Services.Overlay.GetOverlay(ChannelSession.Services.Overlay.DefaultOverlayName); if (overlay != null) { string message = await this.ReplaceStringWithSpecialModifiers(this.SpeechText, user, arguments); await overlay.SendTextToSpeech(new OverlayTextToSpeech() { Text = message, Voice = this.Voice, Volume = this.Volume, Pitch = this.Pitch, Rate = this.Rate }); } }
private async Task WidgetsBackgroundUpdate(CancellationToken token) { token.ThrowIfCancellationRequested(); UserViewModel user = ChannelSession.GetCurrentUser(); foreach (var widgetGroup in ChannelSession.Settings.OverlayWidgets.GroupBy(ow => ow.OverlayName)) { IOverlayEndpointService overlay = this.GetOverlay(widgetGroup.Key); if (overlay != null) { overlay.StartBatching(); foreach (OverlayWidgetModel widget in widgetGroup) { try { if (!widget.Item.IsInitialized) { await widget.Initialize(); } if (widget.IsEnabled) { if (!widget.Item.IsEnabled) { await widget.Enable(); } else if (widget.SupportsRefreshUpdating && widget.RefreshTime > 0 && (this.updateSeconds % widget.RefreshTime) == 0) { await widget.UpdateItem(); } } else { if (widget.Item.IsEnabled) { await widget.Disable(); } } } catch (Exception ex) { Logger.Log(ex); } } await overlay.EndBatching(); } } this.updateSeconds++; }
protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments) { string audioFilePath = await ReplaceStringWithSpecialModifiers(this.FilePath, null); if (SoundAction.MixItUpOverlay.Equals(this.OutputDevice)) { IOverlayEndpointService overlay = ChannelSession.Services.Overlay.GetOverlay(ChannelSession.Services.Overlay.DefaultOverlayName); if (overlay != null) { var overlayItem = new OverlaySoundItemModel(audioFilePath, this.VolumeScale); //await overlay.ShowItem(overlayItem, user, arguments, this.extraSpecialIdentifiers, this.platform); } } else { await ChannelSession.Services.AudioService.Play(audioFilePath, this.VolumeScale, this.OutputDevice); } }
private void Overlay_OnWebSocketDisconnectedOccurred(object sender, WebSocketCloseStatus closeStatus) { IOverlayEndpointService overlay = (IOverlayEndpointService)sender; this.OnOverlayDisconnectedOccurred(overlay, closeStatus); }
public async Task Play(string filePath, int volume, string deviceName) { if (!string.IsNullOrEmpty(filePath)) { if (string.IsNullOrEmpty(deviceName)) { deviceName = ChannelSession.Settings.DefaultAudioOutput; } if (this.MixItUpOverlay.Equals(deviceName)) { IOverlayEndpointService overlay = ChannelSession.Services.Overlay.GetOverlay(ChannelSession.Services.Overlay.DefaultOverlayName); if (overlay != null) { var overlayItem = new OverlaySoundItemModel(filePath, volume); await overlay.ShowItem(overlayItem, new CommandParametersModel()); } } else { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Task.Run(async() => { int deviceNumber = -1; if (!string.IsNullOrEmpty(deviceName)) { deviceNumber = this.GetOutputDeviceID(deviceName); } float floatVolume = MathHelper.Clamp(volume, 0, 100) / 100.0f; using (WaveOutEvent outputDevice = (deviceNumber < 0) ? new WaveOutEvent() : new WaveOutEvent() { DeviceNumber = deviceNumber }) { WaveStream waveStream = null; if (File.Exists(filePath)) { AudioFileReader audioFile = new AudioFileReader(filePath); audioFile.Volume = floatVolume; waveStream = audioFile; } else if (filePath.StartsWith("http", StringComparison.InvariantCultureIgnoreCase)) { waveStream = new MediaFoundationReader(filePath); outputDevice.Volume = floatVolume; } if (waveStream != null) { outputDevice.Init(waveStream); outputDevice.Play(); while (outputDevice.PlaybackState == PlaybackState.Playing) { await Task.Delay(500); } waveStream.Dispose(); } } }); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } } }