-1

A remote bluetooth headset is playing audio from computer. E.g., browser, spotify audio to a bluetooth headset. We want to stop/ pause music/audio from our app. How can we do it?

Searched for methods but did not find solution.

  • See [Send MediaPlayPause](https://stackoverflow.com/questions/7199203/send-key-mediaplaypause-to-an-application-without-setting-focus-to-it). – JonasH Jun 15 '23 at 08:15

1 Answers1

2

UWP

UWP apps are running in sandbox which are isolated from system, UWP cannot access other app's process and is restricted when accessing system resources. So, you can't stop/pause music/audio played by system or other Apps.


WinForm

You can use Win32 API keybd_event with VK_MEDIA_PLAY_PAUSE to simulate pause key input.

Junjie Zhu - MSFT
  • 2,086
  • 1
  • 2
  • 6
  • Hi, How to detect if music is playing? Since play pause will start playing if it was paused? We need only pause state actually. – MARJAN KHAN Jun 19 '23 at 08:30
  • WinForm, you can refer to [this](https://stackoverflow.com/questions/45422255/determine-if-windows-is-currently-playing-sound). It use [IAudioMeterInformation::GetPeakValue](https://learn.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudiometerinformation-getpeakvalue) to detect if music is playing. – Junjie Zhu - MSFT Jun 19 '23 at 09:08