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); } } }
public async Task ShowItem(CommandParametersModel parameters) { IOverlayEndpointService overlay = this.GetOverlay(); if (overlay != null) { await overlay.ShowItem(this.Item, parameters); } }
public async Task ShowItem(UserViewModel user, IEnumerable <string> arguments, Dictionary <string, string> extraSpecialIdentifiers, StreamingPlatformTypeEnum platform) { IOverlayEndpointService overlay = this.GetOverlay(); if (overlay != null) { await overlay.ShowItem(this.Item, user, arguments, extraSpecialIdentifiers, platform); } }
protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments) { string audioFilePath = await this.ReplaceStringWithSpecialModifiers(this.FilePath, user, arguments); 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); } }
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 } } }