473,373 Members | 1,103 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,373 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 4538
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.