Finding MediaLocation for a page item
Hi,
I'm writing an InDesign plugin which needs to query the MediaLocation for any given movie on a page.
I've found 2 ways of doing this: firstly by selecting the page item and accessing the location via IMediaSuite:
IActiveContext* iActiveContext = GetExecutionContextSession()->GetActiveContext ();
ISelectionManager* iSelectionManager = iActiveContext->GetContextSelection();
InterfacePtr<IMediaSuite> ms(iSelectionManager, UseDefaultIID());
if (ms) {
MediaLocation loc;
ms->GetMediaLocation(loc);
}
However, ideally I'd like to not have to select the page item first.
The second way I found avoids having to select it, but does not work for remote movies as they have no link:
UID linkUID = Utils<ILinkUtils>()->FindLink(item);
InterfacePtr<ILinkManager> linkManager(db, db->GetRootUID(), UseDefaultIID());
ILink* link = linkManager->QueryLinkByUID(linkUID);
InterfacePtr<const ILinkObject> linkObj(::GetDataBase(link),link->GetObject(),UseDefaultIID());
InterfacePtr<const IMediaInfo> mediaInfo((IMediaInfo*)linkObj->QueryLinkedObject(IID_IMEDIAINFO));
InterfacePtr<const IMediaContent> mediaContent(mediaInfo,UseDefaultIID());
MediaLocation loc = mediaContent->GetLocation();
Is there a way I can get the MediaLocation for both local and remote movies, without first having to select the page item?
Thanks
Liz