Solved

WindowsMediaPlayer1 Index Number of Currently Playing

Posted on 2009-07-04
7
379 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to center only a line in richedit? 4 59
find a node in VST 2 69
Magic Software info 18 132
Base1 Encode/Decode 3 77
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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…

832 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