Solved

WindowsMediaPlayer1 Index Number of Currently Playing

Posted on 2009-07-04
7
383 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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