471,306 Members | 931 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

getting number of items from curr playlist of windows media player

I have this code which tries to obtain the number of items in the
current playlist of windows media player:

private void MainForm_Load(object sender, System.EventArgs e)
{
// get Window handle
wnd = Win32.FindWindow("WMPlayerApp","Windows Media Player");
wnd = Win32.FindWindowEx(wnd, 0, "WMPAppHost", null);
wnd = Win32.FindWindowEx(wnd, 0, "WMP Skin Host", null);
wnd = Win32.FindWindowEx(wnd, 0, "CWmpControlCntr", null);
wnd = Win32.FindWindowEx(wnd, 0, "WMPPlaylist", null);
wnd = Win32.FindWindowEx(wnd, 0, "ATL:SysListView32", null);

iHandle = Win32.FindWindow("WMPlayerApp", "Windows Media Player");
}

private void button1_Click(object sender, System.EventArgs e)
{
han =Win32.SendMessage(wnd, Win32.LB_GETCOUNT, 0,0);
if(han != Win32.LB_ERR)
{
textBox1.Text = Convert.ToString(han);
}
}

so when i click the button1 i should get the number of items displayed
in my textbox1.
but all i get is 0 even though my current playlist has 5 items and one
of them is currently playing.
has any body any idea why this is happening?
*** Sent via Developersdex http://www.developersdex.com ***
Jan 14 '06 #1
5 4366
Maybe beacuse the code in MainForm_Load cannot find specified window?
There can be different reasons why this is happening:
- there is not such window ( check windows with Spy++ tool )
- bug in the Win32 class

Also you do not check if
wnd = Win32.FindWindow("WMPlayerApp","Windows Media Player");
returned valid wnd handle.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"Paul Fi" <na*******@hotmail.com> wrote in message
news:Og**************@TK2MSFTNGP12.phx.gbl...
I have this code which tries to obtain the number of items in the
current playlist of windows media player:

private void MainForm_Load(object sender, System.EventArgs e)
{
// get Window handle
wnd = Win32.FindWindow("WMPlayerApp","Windows Media Player");
wnd = Win32.FindWindowEx(wnd, 0, "WMPAppHost", null);
wnd = Win32.FindWindowEx(wnd, 0, "WMP Skin Host", null);
wnd = Win32.FindWindowEx(wnd, 0, "CWmpControlCntr", null);
wnd = Win32.FindWindowEx(wnd, 0, "WMPPlaylist", null);
wnd = Win32.FindWindowEx(wnd, 0, "ATL:SysListView32", null);

iHandle = Win32.FindWindow("WMPlayerApp", "Windows Media Player");
}

private void button1_Click(object sender, System.EventArgs e)
{
han =Win32.SendMessage(wnd, Win32.LB_GETCOUNT, 0,0);
if(han != Win32.LB_ERR)
{
textBox1.Text = Convert.ToString(han);
}
}

so when i click the button1 i should get the number of items displayed
in my textbox1.
but all i get is 0 even though my current playlist has 5 items and one
of them is currently playing.
has any body any idea why this is happening?
*** Sent via Developersdex http://www.developersdex.com ***

Jan 14 '06 #2
no it can find the window because i can send other messages like
play/pause and stop playing messages to windows media player current
track, but getcount message is returning 0

*** Sent via Developersdex http://www.developersdex.com ***
Jan 14 '06 #3
did you check the result of
wnd = Win32.FindWindowEx(wnd, 0, "ATL:SysListView32", null);
can you call GetLastError if the han is equal to LB_ERR?
--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"Paul Fi" <na*******@hotmail.com> wrote in message
news:u2*************@TK2MSFTNGP12.phx.gbl...
no it can find the window because i can send other messages like
play/pause and stop playing messages to windows media player current
track, but getcount message is returning 0

*** Sent via Developersdex http://www.developersdex.com ***

Jan 14 '06 #4
dude its in the code above if it was ERR it wont assign the text value
of the han to the textbox1 that is why its returning 0 to the
textbox.text proprty

*** Sent via Developersdex http://www.developersdex.com ***
Jan 14 '06 #5

im writing a C# program that tries to get the currently playing song in
a
seperate windows media player instance (external app)

i found out that there might be a way to do that using the windows
messaging
system.

some how i was able to use the win32 funtion findwindow() to get the
handle
for windows media player host, systemlistview32 and for wmpplaylist
using
spy++.

but now im trying to use the win32 function sendmessage() to get at
least
the index of the currently playing song in windows media player, and i
still
cant figure this out

does anyone know how to do that?
*** Sent via Developersdex http://www.developersdex.com ***
Jan 21 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by UJ | last post: by
reply views Thread by varunk | last post: by
reply views Thread by =?Utf-8?B?Um9iZXJ0?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.