Solved

WindowsMediaPlayer1 Index Number of Currently Playing

Posted on 2009-07-04
7
390 Views
Last Modified: 2012-05-07
Hi, is there anyway of getting the index of the current playing media?

like we have listview1.selected.index and it gives us the index [1], I'd like to be able to show the index of the media that is currently playing.

is there anyway of doing this?

for examples you'll have to import the activex windows media player dll which is on your computer.
0
Comment
Question by:eNarc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24781118
is this the same Q as your previous Q in this TA ?

i found this on msdn (for C coders ...)
http://msdn.microsoft.com/en-us/library/dd564119(VS.85).aspx

and this code may be very helpfull
http://msdn.microsoft.com/en-us/library/dd564128(VS.85).aspx

i haven't used this code, so can't really help much further
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24781123
i would delete your other Q if the same
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 total points
ID: 24797267
I'm not sure if this is correct because I can't test it but give it a try:

function getCurrentMediaIndex(WMP: TWindowsMediaPlayer; cm: IWMPMedia): Integer;
var
  pl: IWMPPlaylist;
  pm: IWMPMedia;
  i: Integer;
begin
  Result := -1;
  pl := WMP.currentPlaylist;
  for i := 0 to pl.count-1 do
  begin
    pm := pl.Item[i];
    // Not sure if this is the property or attribute to check
    if pm.name = cm.name then
      Result := i;
  end;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
var
  cm: IWMPMedia;
begin
  cm := WMP1.currentMedia;
  ShowMessage(IntToStr(getCurrentMediaIndex(WMP1, cm)));
end;

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:eNarc
ID: 24797590
Works Perfectly :D thankyou
0
 
LVL 5

Author Comment

by:eNarc
ID: 35929975
a new way, simpler and works with same files in playlist.
function MediaIndex:integer;
var
  i:integer;
begin
with form1 do
  for i := 0 to WindowsMediaPlayer1.currentPlaylist.Count - 1 do
    if WindowsMediaPlayer1.currentPlaylist.Item[i].isIdentical[WindowsMediaPlayer1.currentMedia] = true then
      Result:=i;
end;

Open in new window

0
 
LVL 5

Author Comment

by:eNarc
ID: 35931172
just found another much faster and simpler way.
wm:= WindowsMediaPlayer1.controlinterface.mediaCollection.add(FileProcess[i]);
wm.setItemInfo('index',inttostr(WindowsMediaPlayer1.controlinterface.currentplaylist.count));
WindowsMediaPlayer1.controlinterface.currentPlaylist.insertItem(WindowsMediaPlayer1.controlinterface.currentplaylist.count,wm);
ShowMessage(wm.getItemInfo('index'));

Open in new window

0
 
LVL 5

Author Comment

by:eNarc
ID: 35931185
Caption:=WindowsMediaPlayer1.currentMedia.getItemInfo('index');
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question