473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 4544
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Emil | last post by:
This is my problem: I'm writing a script that... 1. creates a customized pls/m3u playlist 2. sends the pls or a m3u playlist to the webbrowser. The browser should open Winamp/Windows Media...
1
by: manoj | last post by:
hi, I am developing a Player like windows media player. I added some components from WMP. I want to load a playlist directly when .wpl file is loaded , can some one tell me how to do it. for...
1
by: Stephen Adam | last post by:
Hi there, Have spent a while trying to find out how to connect to Windows Media Player through COM. Unfortunately there doesnt seem to be much stuff about it on the web. What I need to do is...
3
by: UJ | last post by:
I have a .avi file that uses the Divx codec. If I load it with windows media player program it works fine. If I load it using my control in a program, it doesn't display. Over standard media files...
1
by: Paul Fi | last post by:
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...
19
by: Tony | last post by:
I'm working on project that plays movies using Windows Media Player and I'm controlling everything with JavaScript. Per the client I only need to support IE 6 or greater which happens to make...
0
by: varunk | last post by:
Hi I was trying to implement playlist in c#.I have 2 types of files ".flv" ".swf" in the folder. The problem is when I create xml from code behind..I dont know how to read it ... Here is the...
0
by: =?Utf-8?B?Um9iZXJ0?= | last post by:
I am not a novice user but this one really is a puzzle. When ever I use Media player to burn songs to a blank cd it creates duplicate songs on the CD. Sometimes they are one after another and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.