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 bool InitializeInterface( bool server ) { SetInterface( server, new ISteamMusic( server ) ); if ( Interface is null || Interface.Self == IntPtr.Zero ) return false; InstallEvents(); return true; } internal static void InstallEvents() { Dispatch.Install( x => OnPlaybackChanged?.Invoke() ); Dispatch.Install( x => OnVolumeChanged?.Invoke( x.NewVolume ) ); } /// /// Invoked when playback status is changed. /// public static event Action? OnPlaybackChanged; /// /// Invoked when the volume of the music player is changed. /// public static event Action? OnVolumeChanged; /// /// Checks if Steam Music is enabled. /// public static bool IsEnabled => Internal != null && Internal.BIsEnabled(); /// /// if a song is currently playing, paused, or queued up to play; otherwise . /// public static bool IsPlaying => Internal != null && Internal.BIsPlaying(); /// /// Gets the current status of the Steam Music player /// public static MusicStatus Status => Internal?.GetPlaybackStatus() ?? MusicStatus.Undefined; /// /// Plays the music player. /// public static void Play() => Internal?.Play(); /// /// Pauses the music player. /// public static void Pause() => Internal?.Pause(); /// /// Forces the music player to play the previous song. /// public static void PlayPrevious() => Internal?.PlayPrevious(); /// /// Forces the music player to skip to the next song. /// public static void PlayNext() => Internal?.PlayNext(); /// /// Gets and sets the current volume of the Steam Music player /// public static float Volume { get => Internal?.GetVolume() ?? 0f; set => Internal?.SetVolume( value ); } } }