mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 14:15:47 +03:00
Music
This commit is contained in:
parent
db1cfde383
commit
9cf553a786
129
Facepunch.Steamworks/Generated/Interfaces/ISteamMusic.cs
Normal file
129
Facepunch.Steamworks/Generated/Interfaces/ISteamMusic.cs
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SteamNative;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Steamworks.Internal
|
||||||
|
{
|
||||||
|
public class ISteamMusic : BaseSteamInterface
|
||||||
|
{
|
||||||
|
public override string InterfaceName => "STEAMMUSIC_INTERFACE_VERSION001";
|
||||||
|
|
||||||
|
public override void InitInternals()
|
||||||
|
{
|
||||||
|
BIsEnabledDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsEnabledDelegate>( Marshal.ReadIntPtr( VTable, 0) );
|
||||||
|
BIsPlayingDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsPlayingDelegate>( Marshal.ReadIntPtr( VTable, 8) );
|
||||||
|
GetPlaybackStatusDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetPlaybackStatusDelegate>( Marshal.ReadIntPtr( VTable, 16) );
|
||||||
|
PlayDelegatePointer = Marshal.GetDelegateForFunctionPointer<PlayDelegate>( Marshal.ReadIntPtr( VTable, 24) );
|
||||||
|
PauseDelegatePointer = Marshal.GetDelegateForFunctionPointer<PauseDelegate>( Marshal.ReadIntPtr( VTable, 32) );
|
||||||
|
PlayPreviousDelegatePointer = Marshal.GetDelegateForFunctionPointer<PlayPreviousDelegate>( Marshal.ReadIntPtr( VTable, 40) );
|
||||||
|
PlayNextDelegatePointer = Marshal.GetDelegateForFunctionPointer<PlayNextDelegate>( Marshal.ReadIntPtr( VTable, 48) );
|
||||||
|
SetVolumeDelegatePointer = Marshal.GetDelegateForFunctionPointer<SetVolumeDelegate>( Marshal.ReadIntPtr( VTable, 56) );
|
||||||
|
GetVolumeDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetVolumeDelegate>( Marshal.ReadIntPtr( VTable, 64) );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region FunctionMeta
|
||||||
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
|
[return: MarshalAs( UnmanagedType.I1 )]
|
||||||
|
public delegate bool BIsEnabledDelegate( IntPtr self );
|
||||||
|
private BIsEnabledDelegate BIsEnabledDelegatePointer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
public bool BIsEnabled()
|
||||||
|
{
|
||||||
|
return BIsEnabledDelegatePointer( Self );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region FunctionMeta
|
||||||
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
|
[return: MarshalAs( UnmanagedType.I1 )]
|
||||||
|
public delegate bool BIsPlayingDelegate( IntPtr self );
|
||||||
|
private BIsPlayingDelegate BIsPlayingDelegatePointer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
public bool BIsPlaying()
|
||||||
|
{
|
||||||
|
return BIsPlayingDelegatePointer( Self );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region FunctionMeta
|
||||||
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
|
public delegate AudioPlayback_Status GetPlaybackStatusDelegate( IntPtr self );
|
||||||
|
private GetPlaybackStatusDelegate GetPlaybackStatusDelegatePointer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
public AudioPlayback_Status GetPlaybackStatus()
|
||||||
|
{
|
||||||
|
return GetPlaybackStatusDelegatePointer( Self );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region FunctionMeta
|
||||||
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
|
public delegate void PlayDelegate( IntPtr self );
|
||||||
|
private PlayDelegate PlayDelegatePointer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
public void Play()
|
||||||
|
{
|
||||||
|
PlayDelegatePointer( Self );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region FunctionMeta
|
||||||
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
|
public delegate void PauseDelegate( IntPtr self );
|
||||||
|
private PauseDelegate PauseDelegatePointer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
public void Pause()
|
||||||
|
{
|
||||||
|
PauseDelegatePointer( Self );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region FunctionMeta
|
||||||
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
|
public delegate void PlayPreviousDelegate( IntPtr self );
|
||||||
|
private PlayPreviousDelegate PlayPreviousDelegatePointer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
public void PlayPrevious()
|
||||||
|
{
|
||||||
|
PlayPreviousDelegatePointer( Self );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region FunctionMeta
|
||||||
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
|
public delegate void PlayNextDelegate( IntPtr self );
|
||||||
|
private PlayNextDelegate PlayNextDelegatePointer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
public void PlayNext()
|
||||||
|
{
|
||||||
|
PlayNextDelegatePointer( Self );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region FunctionMeta
|
||||||
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
|
public delegate void SetVolumeDelegate( IntPtr self, float flVolume );
|
||||||
|
private SetVolumeDelegate SetVolumeDelegatePointer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
public void SetVolume( float flVolume )
|
||||||
|
{
|
||||||
|
SetVolumeDelegatePointer( Self, flVolume );
|
||||||
|
}
|
||||||
|
|
||||||
|
#region FunctionMeta
|
||||||
|
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||||
|
public delegate float GetVolumeDelegate( IntPtr self );
|
||||||
|
private GetVolumeDelegate GetVolumeDelegatePointer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
public float GetVolume()
|
||||||
|
{
|
||||||
|
return GetVolumeDelegatePointer( Self );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
82
Facepunch.Steamworks/Redux/Music.cs
Normal file
82
Facepunch.Steamworks/Redux/Music.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SteamNative;
|
||||||
|
|
||||||
|
namespace Steamworks
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Undocumented Parental Settings
|
||||||
|
/// </summary>
|
||||||
|
public static class Music
|
||||||
|
{
|
||||||
|
static Internal.ISteamMusic _internal;
|
||||||
|
internal static Internal.ISteamMusic music
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if ( _internal == null )
|
||||||
|
_internal = new Internal.ISteamMusic();
|
||||||
|
|
||||||
|
return _internal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void InstallEvents()
|
||||||
|
{
|
||||||
|
new Event<PlaybackStatusHasChanged_t>( x => OnPlaybackChanged?.Invoke() );
|
||||||
|
new Event<VolumeHasChanged_t>( x => OnVolumeChanged?.Invoke( x.NewVolume ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Playback status changed
|
||||||
|
/// </summary>
|
||||||
|
public static event Action OnPlaybackChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Volume changed, parameter is new volume
|
||||||
|
/// </summary>
|
||||||
|
public static event Action<float> OnVolumeChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if Steam Music is enabled
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsEnabled => music.BIsEnabled();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// true if a song is currently playing, paused, or queued up to play; otherwise false.
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsPlaying => music.BIsPlaying();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current status of the Steam Music player
|
||||||
|
/// </summary>
|
||||||
|
public static AudioPlayback_Status Status => music.GetPlaybackStatus();
|
||||||
|
|
||||||
|
|
||||||
|
public static void Play() => music.Play();
|
||||||
|
|
||||||
|
public static void Pause() => music.Pause();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Have the Steam Music player play the previous song.
|
||||||
|
/// </summary>
|
||||||
|
public static void PlayPrevious() => music.PlayPrevious();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Have the Steam Music player skip to the next song
|
||||||
|
/// </summary>
|
||||||
|
public static void PlayNext() => music.PlayNext();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets/Sets the current volume of the Steam Music player
|
||||||
|
/// </summary>
|
||||||
|
public static float Volume
|
||||||
|
{
|
||||||
|
get => music.GetVolume();
|
||||||
|
set => music.SetVolume( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6816,6 +6816,31 @@ public struct Pack8
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct PlaybackStatusHasChanged_t : Steamworks.ISteamCallback
|
||||||
|
{
|
||||||
|
|
||||||
|
#region ISteamCallback
|
||||||
|
public int GetCallbackId() => CallbackIdentifiers.SteamMusic + 1;
|
||||||
|
public int GetStructSize() => System.Runtime.InteropServices.Marshal.SizeOf( Platform.PackSmall ? typeof(Pack4) : typeof(Pack8) );
|
||||||
|
public Steamworks.ISteamCallback Fill( IntPtr p ) => Platform.PackSmall ? ((PlaybackStatusHasChanged_t)(Pack4) Marshal.PtrToStructure( p, typeof(Pack4) )) : ((PlaybackStatusHasChanged_t)(Pack8) Marshal.PtrToStructure( p, typeof(Pack8) ));
|
||||||
|
#endregion
|
||||||
|
#region Packed Versions
|
||||||
|
[StructLayout( LayoutKind.Sequential, Pack = 4 )]
|
||||||
|
public struct Pack4
|
||||||
|
{
|
||||||
|
|
||||||
|
public static implicit operator PlaybackStatusHasChanged_t ( PlaybackStatusHasChanged_t.Pack4 d ) => new PlaybackStatusHasChanged_t{ };
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout( LayoutKind.Sequential, Pack = 8 )]
|
||||||
|
public struct Pack8
|
||||||
|
{
|
||||||
|
|
||||||
|
public static implicit operator PlaybackStatusHasChanged_t ( PlaybackStatusHasChanged_t.Pack8 d ) => new PlaybackStatusHasChanged_t{ };
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
public struct NewUrlLaunchParameters_t : Steamworks.ISteamCallback
|
public struct NewUrlLaunchParameters_t : Steamworks.ISteamCallback
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -7458,6 +7483,7 @@ internal static void RegisterCallbacks( Facepunch.Steamworks.BaseSteamworks stea
|
|||||||
new CallbackHandle<GSStatsReceived_t>( steamworks );
|
new CallbackHandle<GSStatsReceived_t>( steamworks );
|
||||||
new CallbackHandle<GSStatsStored_t>( steamworks );
|
new CallbackHandle<GSStatsStored_t>( steamworks );
|
||||||
new CallbackHandle<GSStatsUnloaded_t>( steamworks );
|
new CallbackHandle<GSStatsUnloaded_t>( steamworks );
|
||||||
|
new CallbackHandle<PlaybackStatusHasChanged_t>( steamworks );
|
||||||
new CallbackHandle<NewUrlLaunchParameters_t>( steamworks );
|
new CallbackHandle<NewUrlLaunchParameters_t>( steamworks );
|
||||||
new CallbackHandle<ItemInstalled_t>( steamworks );
|
new CallbackHandle<ItemInstalled_t>( steamworks );
|
||||||
new CallbackHandle<SteamInventoryDefinitionUpdate_t>( steamworks );
|
new CallbackHandle<SteamInventoryDefinitionUpdate_t>( steamworks );
|
||||||
|
@ -95,6 +95,7 @@ public void ToFolder( string folder )
|
|||||||
GenerateVTableClass( "ISteamApps", $"{folder}../Generated/Interfaces/ISteamApps.cs" );
|
GenerateVTableClass( "ISteamApps", $"{folder}../Generated/Interfaces/ISteamApps.cs" );
|
||||||
GenerateVTableClass( "ISteamUtils", $"{folder}../Generated/Interfaces/ISteamUtils.cs" );
|
GenerateVTableClass( "ISteamUtils", $"{folder}../Generated/Interfaces/ISteamUtils.cs" );
|
||||||
GenerateVTableClass( "ISteamParentalSettings", $"{folder}../Generated/Interfaces/ISteamParentalSettings.cs" );
|
GenerateVTableClass( "ISteamParentalSettings", $"{folder}../Generated/Interfaces/ISteamParentalSettings.cs" );
|
||||||
|
GenerateVTableClass( "ISteamMusic", $"{folder}../Generated/Interfaces/ISteamMusic.cs" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
{
|
{
|
||||||
"structs": [
|
"structs": [
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
"struct": "PlaybackStatusHasChanged_t",
|
||||||
|
"fields": [ ]
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"struct": "NewUrlLaunchParameters_t",
|
"struct": "NewUrlLaunchParameters_t",
|
||||||
"fields": [
|
"fields": [ ]
|
||||||
]
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user