You can use an existing source object as a source for several others objects. Even in external applications on the same machine. For example, to feed MMixer object with a playlist from another process.
There are two ways to do it: with IMSenders interface and its methods or with "mp://" link.
Note please, that you should set a video and audio formats for your source object.
IMSenders gets information about all source MPlatform objects that are running in your system (MFile, MPlaylist MLive etc). Here is an example of how to get a list of senders and select the last one:
MSendersClass senders = new MSendersClass(); int nCount; senders.SendersGetCount(out nCount); M_VID_PROPS vidProps; M_AUD_PROPS AudProps; string strName; senders.SendersGetByIndex(nCount-1, out strName, out vidProps, out AudProps);
Then you can get the object with:
object senderObject; senders.SendersGet(strName, out senderObject);
Then you can use this senderObject as a source of another object with URL. For example:
myPlaylist.PlaylistAdd(senderObject, "", "", ref index, out myItem);
You can use "mp://" link for multiple usages of objects. You should use "mp://"+objectName string as a path to the source. To get objectName you can use IMSenders interface (as above) or use ObjectNameGet method.
Here is an example of URL usage:
MMixerClass myMixer = new MMixerClass(); //here you configure this MMixer string myName; myMixer.ObjectNameGet(out myName); MFileClass myFile = new MFileClass(); myFile.FileNameSet("mp://"+myName, ""); myFile.ObjectStart(null); myFile.FilePlayStart();
MP:// source duration
By default, all mp:// sources have default duration = 3600 seconds (1 hour)
MMixerClass myMixer = new MMixerClass(); string myName; myMixer.ObjectNameGet(out myName); myPlaylist.PlaylistAdd(null, "mp://"+myName, "", ref index, out myItem);
In the current scenario, myItem duration in playlist object will be 3600 seconds (1 hour). After 1 hour playback, the playlist will be switched to the next item. If myItem the only item in playlist and loop property set to true, myItem will be played again. Even if mp:// source is a Live object it will behave like a simple file with 1-hour duration.
You can change mp:// source default duration via additional parameters in PlaylistAdd method
myPlaylist.PlaylistAdd(null, "mp://"+myName, "duration=7200", ref index, out myItem);
or via IMProps interface
MItem myItem; myPlaylist.PlaylistAdd(null, "mp://"+myName, "", ref index, out myItem); (myItem as IMProps).PropsSet("file::duration", "7200")
In- and out-points for mp:// sources
If you use in- or out-point with your mp://-source you should check that out point is greater your current mp://-source duration. For example
myPlaylist.PlaylistAdd(null, "mp://"+myName, "out=3800.0", ref index, out myItem);
After adding your mp://source with out=3800 and default mp://-source duration=3600 you will notice that after 1-hour (duration=3600 seconds) playback you will continue to get the last frame from mp:// source.
It happens only in the case when mp://-source out-point is greater than mp://source duration, by default if you set out point greater than item duration playlist will continue to show the item last frame without a sound until out point will be reached.
In the case when we are using mp:// link to MLive source and out point greater current duration, playlist continue to get frames from mp:// source without a sound until outpoint will be reached. The difference between mp:// link regular file and mp:// MLive source, that regular file has constant last frame while mp://MLive source will return the new frame each time as the last one - in result you will still able to see MLive video but without a sound.
For avoiding current behavior you should always set duration greater than out point.