How can I determine the process that playing sound via C#? - c#

I use one music player and I'd like to develop a plugin for it in C#.
The plugin should stop playing, when others programs start playing, for example youtube in Chrome or Skype.
Is it possible to monitor all sound sources in Windows via C# or any other language?

Related

How to launch an external MP3 player without taking focus?

I am writing a desktop C# app to manage my MP3 library (it's essentially a bulk MP3 tag editor) and I want to be able to play songs while working on the library.
I do not want to embed a music player into my app and I am happy with whatever my system has configured to play music (in my case I have Groove Music set as a default player on Windows 10).
Launching a song is easy: simply call Process.Start(songPath);. The trouble is that Groove Music steals focus which is annoying because it breaks my work flow.
How can I launch an external music player so that it plays in the background and doesn't steal focus?
I have tried https://stackoverflow.com/a/19049930/497403 with the following command lines:
cmd.exe songPath
"c:\Program Files (x86)\Windows Media Player\wmplayer.exe" songPath
However, in both cases the music player window (Grove in the first case, Media Player in the second) still comes into foreground and steals focus.
I suppose I could, as a workaround, just embed Windows Media Player ActiveX in my app, but I'm still curious why I cannot get WMPlayer to start without grabbing focus, with SW_SHOWNOACTIVATE/SW_SHOWMINNOACTIVE and what-not.

Getting data from any sound currently playing on an android device?

I am interested to get any sound currently playing on a mobile device, even if it is not playing using the app. Is it possible to monitor the speakers, and get data directly before they play that sound? Like when you plug in the headphones and the speaker stops, but android sends the data to the headset, no matter, where it is playing. If it is, what would be the code?
I did look at this, but this should get only if it is playing or not, and not actuall song data.
Xamarin Android: Detect if audio is currently playing on device
You could try to use the microphone, except when earphones are connected, like Shazam does or the ROG phone to sync the rgb with the audio.

How to detect media playing with C#?

I would like to know how to detect if current windows is playing any kind of media (video, music, etc) similar to what energy settings do to decide if the computer can enter sleep/hibernate mode?
I'm trying to detect how long the computer is idle. I'm currently using the GetLastInputInfo from user32.dll but it just take in consideration the user input, but not if there is any media playing which should not consider the computer idle.
I tried to find C# APIs or native invocations but can't find the information. I'm using latest version of .NET Framework.
Generally speaking, programs don't declare that they are playing media - instead they call SetThreadExecutionState to tell Windows that the computer should not sleep.
That said - Windows 10 recently added support for programs to declare to the OS that they are currently playing media so that they're integrated with Windows' media controls (like how on iOS any program playing video or audio can be controlled from the Control Center).
Here's what appears on my screen when I nudge my volume control:
...however Chrome is being buggy here because I'm not actually playing any media in Chrome but it's telling Windows that it is.
I don't know what Windows API is used to set this - or which API is used to check it - but it isn't very widely used - even Windows' built-in Windows Media Player 12 doesn't use it.

C# video player that supports streaming?

I want to add a video player in my Windows Form that would be able to stream videos (flv) from internet (web-server). So far i've tried Microsoft Windows Media Player and it's working but I don't like it because of its lags and bugs and etc.
So are there any other video players that can be easily embedded in a Windows Form and that support video streaming? (by streaming I don't mean something like live TV streaming, but just downloading (buffering) and playing at the same time the video)
Perhaps you can embed VLC as an ActiveX component?
There is a Flash ActiveX control which (I expect) would handle these natively.

play 3gp videos on windows mobile 5 and 6 from code?

currently im able to play .wmv videos from my application using shell execute which plays it in the windowsmedia player. However I need to be able to play .3gp videos which unfortunately the windows meadia player does not support. Is it possible via api etc to play 3gp videos on win mobile 5 and 6 devices?
You can check out CorePlayer, though you need to purchase a license. I am not familiar with a free solution to play this media unless the device's OEM provides it.

Categories

Resources