Skip to main content
Inspiring
July 4, 2014
Answered

Finding MediaLocation for a page item

  • July 4, 2014
  • 1 reply
  • 389 views

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

This topic has been closed for replies.
Correct answer Bartek_Kropaczewski

Hi Liz

You don't need to search for Link to access IMediaContent. You access IMediaContent from page items that are:
- kMediaPageItemBoss

- kMoviePageItemBoss

- kSoundPageItemBoss

So if you have an UIDRef to graphic frame (kSplineItemBoss), you need to use IHierarchy inteface to get the correct page item.

You can can verify if this is correct page item using

Utils<IMediaUtils>()->IsMediaItem( kMoviePageItemBoss, yourUID, youDB)

And then

InterfacePtr<const IMediaContent> mediaContent(youDB, yourUID, UseDefaultIID());

MediaLocation loc = mediaContent->GetLocation();

PMString theStr = loc.GetString();

From MediaLocation you can get iformation if that's remote URL or local File

Regards

Bartek

1 reply

Bartek_Kropaczewski
Bartek_KropaczewskiCorrect answer
Inspiring
July 4, 2014

Hi Liz

You don't need to search for Link to access IMediaContent. You access IMediaContent from page items that are:
- kMediaPageItemBoss

- kMoviePageItemBoss

- kSoundPageItemBoss

So if you have an UIDRef to graphic frame (kSplineItemBoss), you need to use IHierarchy inteface to get the correct page item.

You can can verify if this is correct page item using

Utils<IMediaUtils>()->IsMediaItem( kMoviePageItemBoss, yourUID, youDB)

And then

InterfacePtr<const IMediaContent> mediaContent(youDB, yourUID, UseDefaultIID());

MediaLocation loc = mediaContent->GetLocation();

PMString theStr = loc.GetString();

From MediaLocation you can get iformation if that's remote URL or local File

Regards

Bartek

LizWAuthor
Inspiring
July 4, 2014

Ahhh as simple as that! Thanks