-
Notifications
You must be signed in to change notification settings - Fork 78
[FEAT] Add Media widget #13
base: main
Are you sure you want to change the base?
Conversation
… up rebase with master
… up rebase with master
|
The following code returns a # media.py
import winsdk.windows.media.control
import asyncio
import json
async def get_media_info():
session_manager = await winsdk.windows.media.control.GlobalSystemMediaTransportControlsSessionManager.request_async()
current_session = session_manager.get_current_session()
media_properties = await current_session.try_get_media_properties_async()
media_playback_info = {
"title": media_properties.title,
"artist": media_properties.artist,
"album": media_properties.album_title,
"album_artist": media_properties.album_artist,
"track": media_properties.track_number
}
print(json.dumps(media_playback_info))
asyncio.run(get_media_info())When paired with a # config.yaml
widgets:
media:
type: "yasb.custom.CustomWidget"
options:
label: "{data[title]} - {data[artist]}"
label_alt: "{data[album]}"
class_name: "media-widget"
exec_options:
run_cmd: 'python.exe PATH_TO_PYTHON_FILE' # Paste the above code into a Python file and reference it here
run_interval: 5000
return_format: "json"Of course, this isn't a complete solution (no album artwork or media controls), but is a simple way to display basic media information in a widget, at least until the |
|
I wish I had seen this FEAT before spending several hours last night trying to build a widget for this. 🤦 (Still had fun though 😅) |
|
@hexfactor hello i tried your media player workaround and it doesnt work and gives me these errors |
|
@Welpyes the problem for me was because there was a double space between if you delete one of the spaces in the run_cmd for this widget it should work or you can add something like the following to protect against this in general |
|
I have tried recreating this widget in Python v12, but failed every time, if anyone knows how to get it work, can you pls add a pr in My YASB fork |

Pull Request #XX
New widget, config validation, and stylesheet changes.
Description
Adds a win32 media player widget. Allows user to view / control currently playing media directly via the status bar.