Solved

WindowsMediaPlayer1 Index Number of Currently Playing

Posted on 2009-07-04
7
366 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 36

Expert Comment

by:Geert Gruwez
Comment Utility
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 36

Expert Comment

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

Accepted Solution

by:
EddieShipman earned 500 total points
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 5

Author Comment

by:eNarc
Comment Utility
Works Perfectly :D thankyou
0
 
LVL 5

Author Comment

by:eNarc
Comment Utility
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
Comment Utility
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
Comment Utility
Caption:=WindowsMediaPlayer1.currentMedia.getItemInfo('index');
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

16 Experts available now in Live!

Get 1:1 Help Now