using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BoneLib.BoneMenu; using MelonLoader; using Microsoft.CodeAnalysis; using UnityEngine; using WeatherElectric.BONELAB.BoneMenu; using WeatherElectric.LabMTC; using WeatherElectric.LabMTC.Menu; using WeatherElectric.Logging; using Windows.Foundation; using Windows.Media.Control; using WindowsMediaController; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Allows control over the Windows Media Transport Control system.")] [assembly: AssemblyDescription("Allows control over the Windows Media Transport Control system.")] [assembly: AssemblyCompany("Weather Electric")] [assembly: AssemblyProduct("LabMTC")] [assembly: AssemblyCopyright("Developed by Mabel Amber")] [assembly: AssemblyTrademark("Weather Electric")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: MelonInfo(typeof(Main), "LabMTC", "1.0.0", "Mabel Amber", "https://thunderstore.io/c/bonelab/p/WeatherElectric/LabMTC/")] [assembly: MelonColor(255, 0, 255, 239)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace WeatherElectric.LabMTC { public class Main : MelonMod { internal const string Name = "LabMTC"; internal const string Description = "Allows control over the Windows Media Transport Control system."; internal const string Author = "Mabel Amber"; internal const string Company = "Weather Electric"; internal const string Version = "1.0.0"; internal const string DownloadLink = "https://thunderstore.io/c/bonelab/p/WeatherElectric/LabMTC/"; internal static LoggerInstance Logger; public override void OnInitializeMelon() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown Logger = new LoggerInstance(((MelonBase)this).LoggerInstance); BoneMenu.Setup(); SMTCInterface.Initialize(); } } public static class SMTCInterface { [CompilerGenerated] private static class <>O { public static SessionChangeDelegate <0>__AnySessionOpened; public static SessionChangeDelegate <1>__AnySessionClosed; public static SessionChangeDelegate <2>__FocusedSessionChanged; public static SongChangeDelegate <3>__AnyMediaPropertyChanged; public static PlaybackChangeDelegate <4>__AnyPlaybackStateChanged; public static TimelineChangeDelegate <5>__AnyTimelinePropertyChanged; } private static MediaManager _manager; public static Action OnAnySessionOpened; public static Action OnAnySessionClosed; public static Action OnFocusedSessionChanged; public static Action OnAnyMediaPropertyChanged; public static Action OnAnyPlaybackStateChanged; public static Action OnAnyTimelinePropertyChanged; internal static void Initialize() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown _manager = new MediaManager(); MediaManager manager = _manager; object obj = <>O.<0>__AnySessionOpened; if (obj == null) { SessionChangeDelegate val = AnySessionOpened; <>O.<0>__AnySessionOpened = val; obj = (object)val; } manager.OnAnySessionOpened += (SessionChangeDelegate)obj; MediaManager manager2 = _manager; object obj2 = <>O.<1>__AnySessionClosed; if (obj2 == null) { SessionChangeDelegate val2 = AnySessionClosed; <>O.<1>__AnySessionClosed = val2; obj2 = (object)val2; } manager2.OnAnySessionClosed += (SessionChangeDelegate)obj2; MediaManager manager3 = _manager; object obj3 = <>O.<2>__FocusedSessionChanged; if (obj3 == null) { SessionChangeDelegate val3 = FocusedSessionChanged; <>O.<2>__FocusedSessionChanged = val3; obj3 = (object)val3; } manager3.OnFocusedSessionChanged += (SessionChangeDelegate)obj3; MediaManager manager4 = _manager; object obj4 = <>O.<3>__AnyMediaPropertyChanged; if (obj4 == null) { SongChangeDelegate val4 = AnyMediaPropertyChanged; <>O.<3>__AnyMediaPropertyChanged = val4; obj4 = (object)val4; } manager4.OnAnyMediaPropertyChanged += (SongChangeDelegate)obj4; MediaManager manager5 = _manager; object obj5 = <>O.<4>__AnyPlaybackStateChanged; if (obj5 == null) { PlaybackChangeDelegate val5 = AnyPlaybackStateChanged; <>O.<4>__AnyPlaybackStateChanged = val5; obj5 = (object)val5; } manager5.OnAnyPlaybackStateChanged += (PlaybackChangeDelegate)obj5; MediaManager manager6 = _manager; object obj6 = <>O.<5>__AnyTimelinePropertyChanged; if (obj6 == null) { TimelineChangeDelegate val6 = AnyTimelinePropertyChanged; <>O.<5>__AnyTimelinePropertyChanged = val6; obj6 = (object)val6; } manager6.OnAnyTimelinePropertyChanged += (TimelineChangeDelegate)obj6; _manager.Start(); } private static void AnySessionOpened(MediaSession mediaSession) { OnAnySessionOpened(mediaSession); } private static void AnySessionClosed(MediaSession mediaSession) { OnAnySessionClosed(mediaSession); } private static void FocusedSessionChanged(MediaSession mediaSession) { OnFocusedSessionChanged(mediaSession); } private static void AnyMediaPropertyChanged(MediaSession mediaSession, GlobalSystemMediaTransportControlsSessionMediaProperties mediaProperties) { OnAnyMediaPropertyChanged(mediaSession, mediaProperties); } private static void AnyPlaybackStateChanged(MediaSession mediaSession, GlobalSystemMediaTransportControlsSessionPlaybackInfo playbackInfo) { OnAnyPlaybackStateChanged(mediaSession, playbackInfo); } private static void AnyTimelinePropertyChanged(MediaSession mediaSession, GlobalSystemMediaTransportControlsSessionTimelineProperties timelineProperties) { OnAnyTimelinePropertyChanged(mediaSession, timelineProperties); } public static MediaSession GetFocusedSession() { return _manager.GetFocusedSession(); } public static IReadOnlyDictionary GetAllMediaSessions() { return _manager.CurrentMediaSessions; } public static async void Play() { try { if (_manager.GetFocusedSession() != null) { TaskAwaiter taskAwaiter = WindowsRuntimeSystemExtensions.GetAwaiter(_manager.GetFocusedSession().ControlSession.TryPlayAsync()); if (!taskAwaiter.IsCompleted) { await taskAwaiter; TaskAwaiter taskAwaiter2 = default(TaskAwaiter); taskAwaiter = taskAwaiter2; } taskAwaiter.GetResult(); } } catch (Exception value) { Main.Logger.Log($"Exception Caught: {value}", (LogLevel)2); } } public static async void Pause() { try { if (_manager.GetFocusedSession() != null) { TaskAwaiter taskAwaiter = WindowsRuntimeSystemExtensions.GetAwaiter(_manager.GetFocusedSession().ControlSession.TryPauseAsync()); if (!taskAwaiter.IsCompleted) { await taskAwaiter; TaskAwaiter taskAwaiter2 = default(TaskAwaiter); taskAwaiter = taskAwaiter2; } taskAwaiter.GetResult(); } } catch (Exception value) { Main.Logger.Log($"Exception Caught: {value}", (LogLevel)2); } } public static async void Next() { try { if (_manager.GetFocusedSession() != null) { TaskAwaiter taskAwaiter = WindowsRuntimeSystemExtensions.GetAwaiter(_manager.GetFocusedSession().ControlSession.TrySkipNextAsync()); if (!taskAwaiter.IsCompleted) { await taskAwaiter; TaskAwaiter taskAwaiter2 = default(TaskAwaiter); taskAwaiter = taskAwaiter2; } taskAwaiter.GetResult(); } } catch (Exception value) { Main.Logger.Log($"Exception Caught: {value}", (LogLevel)2); } } public static async void Previous() { try { if (_manager.GetFocusedSession() != null) { TaskAwaiter taskAwaiter = WindowsRuntimeSystemExtensions.GetAwaiter(_manager.GetFocusedSession().ControlSession.TrySkipPreviousAsync()); if (!taskAwaiter.IsCompleted) { await taskAwaiter; TaskAwaiter taskAwaiter2 = default(TaskAwaiter); taskAwaiter = taskAwaiter2; } taskAwaiter.GetResult(); } } catch (Exception value) { Main.Logger.Log($"Exception Caught: {value}", (LogLevel)2); } } public static async void Stop() { try { if (_manager.GetFocusedSession() != null) { TaskAwaiter taskAwaiter = WindowsRuntimeSystemExtensions.GetAwaiter(_manager.GetFocusedSession().ControlSession.TryStopAsync()); if (!taskAwaiter.IsCompleted) { await taskAwaiter; TaskAwaiter taskAwaiter2 = default(TaskAwaiter); taskAwaiter = taskAwaiter2; } taskAwaiter.GetResult(); } } catch (Exception value) { Main.Logger.Log($"Exception Caught: {value}", (LogLevel)2); } } public static async void Rewind() { try { if (_manager.GetFocusedSession() != null) { TaskAwaiter taskAwaiter = WindowsRuntimeSystemExtensions.GetAwaiter(_manager.GetFocusedSession().ControlSession.TryRewindAsync()); if (!taskAwaiter.IsCompleted) { await taskAwaiter; TaskAwaiter taskAwaiter2 = default(TaskAwaiter); taskAwaiter = taskAwaiter2; } taskAwaiter.GetResult(); } } catch (Exception value) { Main.Logger.Log($"Exception Caught: {value}", (LogLevel)2); } } public static async void FastForward() { try { if (_manager.GetFocusedSession() != null) { TaskAwaiter taskAwaiter = WindowsRuntimeSystemExtensions.GetAwaiter(_manager.GetFocusedSession().ControlSession.TryFastForwardAsync()); if (!taskAwaiter.IsCompleted) { await taskAwaiter; TaskAwaiter taskAwaiter2 = default(TaskAwaiter); taskAwaiter = taskAwaiter2; } taskAwaiter.GetResult(); } } catch (Exception value) { Main.Logger.Log($"Exception Caught: {value}", (LogLevel)2); } } public static IAsyncOperation GetMediaProperties() { if (_manager.GetFocusedSession() == null) { return null; } return _manager.GetFocusedSession().ControlSession.TryGetMediaPropertiesAsync(); } } } namespace WeatherElectric.LabMTC.Menu { internal static class BoneMenu { private static FunctionElement _currentMedia; private static FunctionElement _currentSession; private const string BaseMediaName = "Playing: "; private const string BaseSessionName = "From: "; public static void Setup() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) Page obj = Menu.MainPage.CreatePage("LabMTC", Color.cyan, 0, true); _currentMedia = obj.CreateFunction("Playing: ", Color.white, (Action)delegate { }); _currentSession = obj.CreateFunction("From: ", Color.white, (Action)delegate { }); obj.CreateFunction("Play", Color.green, (Action)SMTCInterface.Play); obj.CreateFunction("Pause", Color.yellow, (Action)SMTCInterface.Pause); obj.CreateFunction("Next", Color.white, (Action)SMTCInterface.Next); obj.CreateFunction("Previous", Color.white, (Action)SMTCInterface.Previous); SMTCInterface.OnAnyMediaPropertyChanged = (Action)Delegate.Combine(SMTCInterface.OnAnyMediaPropertyChanged, new Action(OnMediaPropertyChanged)); SMTCInterface.OnFocusedSessionChanged = (Action)Delegate.Combine(SMTCInterface.OnFocusedSessionChanged, new Action(OnSessionChanged)); SMTCInterface.OnAnySessionClosed = (Action)Delegate.Combine(SMTCInterface.OnAnySessionClosed, new Action(OnSessionClosed)); } private static void OnMediaPropertyChanged(MediaSession session, GlobalSystemMediaTransportControlsSessionMediaProperties properties) { ((Element)_currentMedia).ElementName = "Playing: " + properties.Title; ((Element)_currentSession).ElementName = "From: " + session.Id; } private static void OnSessionChanged(MediaSession newSession) { IAsyncOperation val = newSession.ControlSession.TryGetMediaPropertiesAsync(); ((Element)_currentMedia).ElementName = "Playing: " + val.GetResults().Title; ((Element)_currentSession).ElementName = "From: " + newSession.ControlSession.SourceAppUserModelId; } private static void OnSessionClosed(MediaSession session) { ((Element)_currentMedia).ElementName = "Playing: "; } } }