Solved

WindowsMediaPlayer1 Index Number of Currently Playing

Posted on 2009-07-04
7
370 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi custom sort exception 6 135
Delphi XE2 application frozen on Windows 10 10 274
Mobile Keyboard covers the display of the TMemo 3 78
Performance of SQL statement 37 98
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now