/// <summary>
 /// When the current audio being played matches the indexes defined within the specified <paramref name="payload"/>, the volume of the audio player is updated.
 /// </summary>
 /// <param name="player">The player; this instance.</param>
 /// <param name="payload">The payload.</param>
 public static void TrySetVolume(this IIndexedAudioPlayer player, AdjustPlaylistFileVolumePayload payload)
 {
     if (player?.Index == payload.Index &&
         player.AudioPlayer != null)
     {
         player.AudioPlayer.Volume = payload.Volume;
     }
 }
Пример #2
0
        public void SetVolume(AdjustPlaylistFileVolumePayload payload)
        {
            lock (_syncRoot)
            {
                // Update the volume of anything playing this file.
                this.PlaylistController.TrySetVolume(payload);
                this.VolumeTester.TrySetVolume(payload);

                // Set the volume on the playlist item, and persist it.
                this.PlaylistController.Playlist[payload.Index].Volume = payload.Volume;
                this.SavePlaylist();
            }
        }
Пример #3
0
        public void TestVolume(AdjustPlaylistFileVolumePayload payload)
        {
            lock (_syncRoot)
            {
                // Ensure the volume tester exists and has the correct device identifier.
                var deviceId = this.PlaylistController.AudioPlayer.DeviceId;
                if (this.VolumeTester == null)
                {
                    this.VolumeTester = new VolumeTester(this.AudioService.GetAudioPlayer(deviceId));
                }

                _ = this.VolumeTester.PlayAsync(payload, deviceId);
            }
        }
Пример #4
0
        /// <summary>
        /// Plays the audio file contained within the specified <paramref name="payload"/> asynchronously.
        /// </summary>
        /// <param name="payload">The payload.</param>
        /// <param name="deviceId">The device identifier.</param>
        /// <returns>The task of playing the audio.</returns>
        public Task PlayAsync(AdjustPlaylistFileVolumePayload payload, string deviceId)
        {
            if (this.AudioPlayer != null)
            {
                // Stop any current volume tests.
                this.AudioPlayer.Stop();

                this.Index = payload.Index;
                this.AudioPlayer.DeviceId = deviceId;

                return(this.AudioPlayer.PlayAsync(payload));
            }

            return(Task.CompletedTask);
        }