Example
====== Playback - Set fade-in time - modular ======
^ by: | Sebastian Beutel, April 2021 |
^ published: | here |
^ description: | set some playbacks' fade-in time, modular macros |
^ remarks: | these macros incorporate some newer syntax details: instruction blocks, custom variables, macros refered in other macros |
{{tag>playback fade-in time modular variable new syntax custom blocks}}
The basic functions are best understood when comparing with [[macros:example:setplaybackfadeintime|]]. When using ''Handles.SetSourceHandle()'' which always refers to the handle index on the current page you need to make sure that there is actually something suitable present in this location - hence, some steps need to be conditional. Additionally when you want to make such macros for n different times and m different playbacks you need to repeat many lines of code.
Using newer syntax with code blocks and custom variables this is way easier: here we create only one macro to set all relevant playbacks' fade time to a variable value (using the block syntax to put a few instructions under one condition). Additionally a number of rather short macros simply sets the time variable to a certain value and then calls the 'apply' macro:
==== functions ====
* [[:macros:function:Handles.SetSourceHandle]]
* [[:macros:function:Playbacks.IsCueHandle]]
* [[:macros:function:ActionScript.SetProperty]]
* [[:macros:function:Playbacks.Editor.SelectLiveCue]]
* [[:macros:function:Handles.ClearSelection]]
* [[:macros:function:UserMacros.RecallMacroById]]
==== affected properties ====
* [[:macros:property:Handles.SourceHandle]]
* [[:macros:property:Playbacks.Editor.SelectedPlayback]]
* [[:macros:property:Playbacks.Editor.Times.CueFadeInTime]]
==== control structures ====
* [[macros:control_structures|step condition]]
==== specials ====
* [[macros:syntax:codeblocks|code blocks]]
* [[macros:syntax:customvariables|custom variables]]
* [[macros:syntax:referingmacros|refering macros]]
===== Code =====
{
Handles.SetSourceHandle("PlaybackWindow", 0);
if (Playbacks.IsCueHandle(Handles.SourceHandle) == true)
{
ActionScript.SetProperty("Playbacks.Editor.SelectedPlayback", Handles.SourceHandle);
Playbacks.Editor.SelectLiveCue();
ActionScript.SetProperty("Playbacks.Editor.Times.CueFadeInTime", Wiki.Macros.SetFadeIn.Time);
}
Handles.ClearSelection();
}
{
Handles.SetSourceHandle("PlaybackWindow", 1);
if (Playbacks.IsCueHandle(Handles.SourceHandle) == true)
{
ActionScript.SetProperty("Playbacks.Editor.SelectedPlayback", Handles.SourceHandle);
Playbacks.Editor.SelectLiveCue();
ActionScript.SetProperty("Playbacks.Editor.Times.CueFadeInTime", Wiki.Macros.SetFadeIn.Time);
}
Handles.ClearSelection();
}
{
Handles.SetSourceHandle("PlaybackWindow", 2);
if (Playbacks.IsCueHandle(Handles.SourceHandle) == true)
{
ActionScript.SetProperty("Playbacks.Editor.SelectedPlayback", Handles.SourceHandle);
Playbacks.Editor.SelectLiveCue();
ActionScript.SetProperty("Playbacks.Editor.Times.CueFadeInTime", Wiki.Macros.SetFadeIn.Time);
}
Handles.ClearSelection();
}
ActionScript.SetProperty("Wiki.Macros.SetFadeIn.Time", time:0)UserMacros.RecallMacroById("Wiki.Macros.SetFadeIn")ActionScript.SetProperty("Wiki.Macros.SetFadeIn.Time", time:1)UserMacros.RecallMacroById("Wiki.Macros.SetFadeIn")
===== Explanation =====
This explains the functional steps within the sequence. For all the other XML details please refer to [[:macros:formats_and_syntax#xml_format|Formats and syntax]]
The **Main macro** ''Wiki.Macros.SetFadeIn'' defines a custom variable ''Wiki.Macros.SetFadeIn.Time'', than selects a number of playbacks, and sets them to this time.
* defining the variable is done in the block ...
* in order to define a variable you need to
* give it an **id** (this also defines the 'full name' of the variable: it's ''macro id''.''variable id'' This also means that if you change the id of the macro you need to change the variable name wherever it is called, e.g. where the variable is set, changed, or read.
* the **type** defines the type of the variable, see also [[macros:types|]]
* the **assembly** is some dotnet specific thing (maybe the variable's scope). I'd guess that ''Avolites.Acw.Titan'' should be a good starting point when testing other variables.
* the **value** is the initial value the variable is set to when being defined.
* after this, selecting a playback and setting its time is all done in one step thanks to the [[macros:syntax:codeblocks|code blocks]] syntax:
* multiple instructions inside one step are bundled with ''{'' curly braces ''}''
* instructions inside code blocks are separated with semicolons '';''
* code blocks are also possible as conditional statements, in a very traditional way like
if (condition)
{
code being executed only if condition is true
}
* for the instructions see [[macros:example:setplaybackfadeintime|]]
The **calling macros** ''Wiki.Macros.SetFadeIn0'', ''Wiki.Macros.SetFadeIn1'' etc. now are really short:
* ''ActionScript.SetProperty("Wiki.Macros.SetFadeIn.Time", time:0)'' sets our cusom variable to a new value
* ''UserMacros.RecallMacroById("Wiki.Macros.SetFadeIn")'' calls our 'main macro' which than sets all playbacks to the new time
===== How to use it =====
- [[:macros:deploying|make this macro available]]
- if you want to add more playbacks to be affected simply add more steps in the 'main macro' ''Wiki.Macros.SetFadeIn''
- if you want to add more fade-teime valus then you only need to add some more 'calling macros'
~~DISCUSSION~~