Reputation: 843
I want to write an application (in c#) that will begin when the kmplayer or winamp starts playing a video, and that needs to know the path of the video file, how can I do that?
Edit:
After some searching, coding and testing now I can do this using sharpamp wrapper, all things while I'm opening my media file with winamp is ok but with kmplayer the filename is always empty.
My plugin code for getting filename is looks like this:
public class ThePlugin : GeneralPlugin
{
public override void Initialize()
{
if (!string.IsNullOrEmpty(Winamp.CurrentSong.Filename))
{
MessageBox.Show(Winamp.CurrentSong.Filename);
}
else
{
MessageBox.Show("File name is empty. ");
}
}
}
the result using km is "File name is empty."
In the Winamp class of sharpamp, there's a method named "UpdateSongData" that contains this line of code:
string filename = SendIPCCommandString(IPCCommand.GetFilename);
this code is for getting filename of playing media, so may be the IPC command of "GetFilename" (here it is: 3031) in this two player was different from each other? Or the problem is another thing?
Upvotes: 0
Views: 1595
Reputation: 58497
Maybe there's an easier approach, but you could try repeatedly doing something like this for winamp (completely untested):
Process[] processes = Process.GetProcessesByName("winamp");
foreach (Process p in processes)
{
string winampTitle = p.MainWindowTitle;
// Check the title to see if it contains a video filename, and do
// something with it..
}
Upvotes: 2