This article is about Medialooks Mixer object and relates only to MPlatfrom.
What is Mixer object?
Mixer object is a powerful feature for mixing different sources(streams, files, devices).
You can find the source code of working applications that illustrate how you can use Mixer object in the Medialooks Sample Folder. We have two application, the main difference between them that one of them is using Medialooks MControls and a little bit harder to understanding.
So for the first look, you can check out the code of the "Basic" application:
"...\MPlatform SDK\Samples Basic\C#\Mixer Sample"
And more powerful Sample that includes the MControls:
"...\MPlatform SDK\Samples Advanced\C#\Mixer Sample"
How to use the Mixer object.
You have to understand that the main activities of the Mixer are happening in the scenes. Only on them, you can see the results of the Mixer works. You can have an infinite number of scenes. So it's a part of programmed logic to create additional scenes, setup, and switch between them according to your requirements.
After you create, initialize, set the preview and start the Mixer object:
m_objMixer = new MMixerClass();
//Initialize preview
m_objMixer.PreviewWindowSet("", panelPreview.Handle.ToInt32());
m_objMixer.PreviewEnable("", checkBoxAudio.Checked ? 1 : 0, checkBoxVideo.Checked ? 1 : 0);
m_objMixer.ObjectStart(null);
you should add streams to your Mixer with StreamsAdd method
MItem pItem;
m_objMixer.StreamsAdd(stream_id, null, [path to your file], "", out pItem, 1.00);
Now you can add this stream to your scene.
When we create the Mixer object creating a default Scene and the main Element that contains all other elements like brunch. So we can add different branches, for example, lives and files and depend on our scenario show or disappear them from the scene.
We need to add our stream as an element to the main(root) element. First, we need to get them with ElementsGetByIndex method:
MElement root;
m_objMixer.ElementsGetByIndex(0, out root);
and add the stream as an element with ElementsAdd method:
MElement pChild;
(root as IMElements).ElementsAdd("", "video", "stream_id=" + strStreamID + " h=0.5 w=0.5 show=1 audio_gain=0", out pChild, 0);
Now, all we have to is startMixer with FilePlayStart method:
m_objMixer.FilePlayStart();
Note, that the audio volume of the Mixer element depends on size, brightness, alpha, spacing from the center and e.t.c. But you can directly set the volume of the element with the audio_gain attribute. And other attributes will not affect volume anymore.
audio_gain = 0 - the original volume.
audio_gain = -100 - mute the audio.