{"id":16154801,"url":"https://github.com/dubyadude/windowsmediacontroller","last_synced_at":"2025-05-16T12:12:02.713Z","repository":{"id":51088254,"uuid":"283354160","full_name":"DubyaDude/WindowsMediaController","owner":"DubyaDude","description":"Allows developers to more easily get information from and interact with the Windows 10/11 OS media interface. (Also referred to Windows System Media Transport Controls (SMTC))","archived":false,"fork":false,"pushed_at":"2024-11-21T23:01:48.000Z","size":412,"stargazers_count":152,"open_issues_count":4,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-13T09:45:29.891Z","etag":null,"topics":["c-sharp","csharp","dotnet","mtc","music","music-player","nuget","smtc","windows","windows-10","windows-11"],"latest_commit_sha":null,"homepage":"https://nuget.org/packages/Dubya.WindowsMediaController","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DubyaDude.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-28T23:59:55.000Z","updated_at":"2025-05-12T21:37:53.000Z","dependencies_parsed_at":"2024-01-20T16:29:06.871Z","dependency_job_id":"bdc5a350-da5a-42d8-889b-7ec201964669","html_url":"https://github.com/DubyaDude/WindowsMediaController","commit_stats":{"total_commits":77,"total_committers":3,"mean_commits":"25.666666666666668","dds":0.5844155844155844,"last_synced_commit":"fefa54ca2cf38f4943ed85e55852247049deda17"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DubyaDude%2FWindowsMediaController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DubyaDude%2FWindowsMediaController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DubyaDude%2FWindowsMediaController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DubyaDude%2FWindowsMediaController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DubyaDude","download_url":"https://codeload.github.com/DubyaDude/WindowsMediaController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254527099,"owners_count":22085919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","csharp","dotnet","mtc","music","music-player","nuget","smtc","windows","windows-10","windows-11"],"created_at":"2024-10-10T01:18:58.272Z","updated_at":"2025-05-16T12:12:02.670Z","avatar_url":"https://github.com/DubyaDude.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Windows Media Controller\n[![NuGet](https://img.shields.io/nuget/vpre/Dubya.WindowsMediaController.svg)](https://nuget.org/packages/Dubya.WindowsMediaController)\n\nThis repository provides a wrapper for developers to more easily get information from and interact with the Windows 10/11 OS media interface (Also referred to Windows System Media Transport Controls (SMTC)). \n\n![Windows 10 Media Interface](https://raw.githubusercontent.com/DubyaDude/WindowsMediaController/master/docs/images/Win10.png)\n\nThis allows for a better understanding and control of the Media Sessions and can have many different applications. Some features include:\n- Control playback on individual Media Sessions (Spotify, Chrome, etc)\n- Get media information of currently playing (Song, Author, Thumbnail, etc)\n\n## Requirements\n- Windows 10 (Build 17763+) or Windows 11\n- The ability to talk to Windows Runtime. (In a majority of cases, this will not be an issue)\n- .NET Framework 4.6.1+ or .NET 5+\n- May need to be able to interact with the desktop\n  - In situations such as being run through Windows Task Scheduler, the application will need an active window to start with, you can hide it afterward.\n### NET Framework:\nFor .NET Framework, I've seen people encountering issues with how the package gets imported. This is caused by using an older format of .NET projects (you can see the newer format being used in [Sample.CMD](https://github.com/DubyaDude/WindowsMediaController/blob/master/Sample.CMD/Sample.CMD.csproj)). If you have this issue, add the package by adding this to the .csproj file.\n\u003cbr\u003e (replacing '2.5.5' with the preferred NuGet version)\n```csproj\n\u003cItemGroup\u003e\n  \u003cPackageReference Include=\"Dubya.WindowsMediaController\"\u003e\n    \u003cVersion\u003e2.5.5\u003c/Version\u003e\n  \u003c/PackageReference\u003e\n\u003c/ItemGroup\u003e\n```\n### NET 5+:\nNET 5 brought along a lot of changes in how WinRT is meant to be accessed. More of that info can be found [here](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-enhance).\n\nIf you're doing a GUI app you **should** be good to go and be able to just import the lib.\n\nHowever, for other cases, your `TargetFramework` in the .csproj file needs to be modified before importing the package.\n\u003cbr\u003e (replacing net6.0 with desired .NET version)\n```csproj\n\u003cTargetFramework\u003enet6.0-windows10.0.22000.0\u003c/TargetFramework\u003e\n```\n\n## How To Use\n### Initialization:\n```csharp\nmediaManager = new MediaManager();\n\nmediaManager.OnAnySessionOpened += MediaManager_OnAnySessionOpened;\nmediaManager.OnAnySessionClosed += MediaManager_OnAnySessionClosed;\nmediaManager.OnFocusedSessionChanged += MediaManager_OnFocusedSessionChanged;\nmediaManager.OnAnyMediaPropertyChanged += MediaManager_OnAnyMediaPropertyChanged;\nmediaManager.OnAnyPlaybackStateChanged += MediaManager_OnAnyPlaybackStateChanged;\nmediaManager.OnAnyTimelinePropertyChanged += MediaManager_OnAnyTimelinePropertyChanged;\n\nmediaManager.Start();\nOR\nawait mediaManager.StartAsync();\n```\n\n### Class Structure:\nMediaManager:\n```csharp\nReadOnlyDictionary\u003cstring, MediaSession\u003e CurrentMediaSessions;\nbool IsStarted { get; }\nGlobalSystemMediaTransportControlsSessionManager WindowsSessionManager { get; }\n\nvoid Start();\nasync Task StartAsync();\nMediaSession GetFocusedSession();\nvoid ForceUpdate();\n\ndelegate void OnAnySessionOpened(MediaManager.MediaSession session);\ndelegate void OnAnySessionClosed(MediaManager.MediaSession session);\ndelegate void OnFocusedSessionChanged(MediaManager.MediaSession session);\ndelegate void OnAnyMediaPropertyChanged(MediaManager.MediaSession sender, GlobalSystemMediaTransportControlsSessionMediaProperties args);\ndelegate void OnAnyPlaybackStateChanged(MediaManager.MediaSession sender, GlobalSystemMediaTransportControlsSessionPlaybackInfo args);\ndelegate void OnAnyTimelinePropertyChanged(MediaSession mediaSession, GlobalSystemMediaTransportControlsSessionTimelineProperties timelineProperties);\n```\nMediaManager.MediaSession:\n```csharp\nreadonly string Id;\nGlobalSystemMediaTransportControlsSession ControlSession { get; }\n\ndelegate void OnSessionClosed(MediaManager.MediaSession session);\ndelegate void OnMediaPropertyChanged(MediaManager.MediaSession sender, GlobalSystemMediaTransportControlsSessionMediaProperties args);\ndelegate void OnPlaybackStateChanged(MediaManager.MediaSession sender, GlobalSystemMediaTransportControlsSessionPlaybackInfo args);\ndelegate void OnTimelinePropertyChanged(MediaSession mediaSession, GlobalSystemMediaTransportControlsSessionTimelineProperties timelineProperties);\n```\n\n### Getting Some Info:\n\n- Getting PlaybackInfo (Seeing what actions are available/Is paused or playing, etc)\n  - Returns: GlobalSystemMediaTransportControlsSessionPlaybackInfo\n  - ``mediaSession.ControlSession.GetPlaybackInfo()``\n\n- Getting current MediaProperties (Currently playing title, author, thumbnail, etc)\n  - Returns: GlobalSystemMediaTransportControlsSessionMediaProperties\n  - ``await mediaSession.ControlSession.TryGetMediaPropertiesAsync()``\n\n### Useful Microsoft Documentations:\n- [GlobalSystemMediaTransportControlsSessionManager](https://docs.microsoft.com/en-us/uwp/api/windows.media.control.globalsystemmediatransportcontrolssessionmanager) - Located in `MediaManager.WindowsSessionManager`. This class allows for events whenever a source's state changes.\n- [GlobalSystemMediaTransportControlsSession](https://docs.microsoft.com/en-us/uwp/api/windows.media.control.globalsystemmediatransportcontrolssession) - Located in `MediaManager.MediaSession.ControlSession`. The Media Session that allows for events whenever the playback state or the media property changes as well as to grab such info whenever desired.\n\n  \n## Samples\n- Sample.CMD - A very barebone console application for developers to get a feel of how their use-case might act.\n\n![Sample.CMD](https://raw.githubusercontent.com/DubyaDude/WindowsMediaController/master/docs/images/Sample.CMD.png)\n\n- Sample.UI - A WPF media controller\n\n![Sample.UI](https://raw.githubusercontent.com/DubyaDude/WindowsMediaController/master/docs/images/Sample.UI.png)\n\n\n## Credit\n- Luca Marini ([Stack Overflow](https://stackoverflow.com/users/13997827/luca-marini)) - Helped me understand the Windows API\n- Google ([materialui](https://github.com/google/material-design-icons)) - Utilizing their play icon to create our icon\n- Kinnara ([ModernWpf](https://github.com/Kinnara/ModernWpf)) - Utilized the ModernWpf library to create the UI sample\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdubyadude%2Fwindowsmediacontroller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdubyadude%2Fwindowsmediacontroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdubyadude%2Fwindowsmediacontroller/lists"}