using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using Steamworks.Data; namespace Steamworks { /// /// Functions to control music playback in the steam client. /// This gives games the opportunity to do things like pause the music or lower the volume, /// when an important cut scene is shown, and start playing afterwards. /// Nothing uses Steam Music though so this can probably get fucked /// public class SteamMusic : SteamClientClass { internal static ISteamMusic Internal => Interface as ISteamMusic; internal override void InitializeInterface( bool server ) { SetInterface( server, new ISteamMusic( server ) ); InstallEvents(); } internal static void InstallEvents() { Dispatch.Install( x => OnPlaybackChanged?.Invoke() ); Dispatch.Install( x => OnVolumeChanged?.Invoke( x.NewVolume ) ); } /// /// Playback status changed /// public static event Action OnPlaybackChanged; /// /// Volume changed, parameter is new volume /// public static event Action OnVolumeChanged; /// /// Checks if Steam Music is enabled /// public static bool IsEnabled => Internal.BIsEnabled(); /// /// true if a song is currently playing, paused, or queued up to play; otherwise false. /// public static bool IsPlaying => Internal.BIsPlaying(); /// /// Gets the current status of the Steam Music player /// public static MusicStatus Status => Internal.GetPlaybackStatus(); public static void Play() => Internal.Play(); public static void Pause() => Internal.Pause(); /// /// Have the Steam Music player play the previous song. /// public static void PlayPrevious() => Internal.PlayPrevious(); /// /// Have the Steam Music player skip to the next song /// public static void PlayNext() => Internal.PlayNext(); /// /// Gets/Sets the current volume of the Steam Music player /// public static float Volume { get => Internal.GetVolume(); set => Internal.SetVolume( value ); } } }