1- ## Screens API
1+ # Screens API
22
3- * [ Getters] ( #getters )
3+ ## Table of Contents
4+
5+ - [ Screens API] ( #screens-api )
6+ - [ Table of Contents] ( #table-of-contents )
7+ - [ Getters] ( #getters )
48 - [ Get areas] ( #get-areas )
59 - [ Get area] ( #get-area )
610 - [ Calculate screen duration] ( #calculate-screen-duration )
711 - [ Get max possible duration] ( #get-max-possible-duration )
8- * [ Setters] ( #setters )
12+ - [ Setters] ( #setters )
913 - [ Set duration] ( #set-duration )
1014 - [ Toggle icon position] ( #toggle-icon-position )
1115 - [ Set lower third settings] ( #set-lower-third-settings )
16+ - [ Return project data] ( #return-project-data )
17+ - [ Save] ( #save )
1218
1319## Getters
1420
1521### Get areas
1622
17- Maps through ` areas ` array and adds it's methods .
23+ Gets areas for current screen .
1824
1925``` js
20- const firstScreen = projectDataInstance .getScreen (0 )
21-
22- firstScreen .getAreas () // array of areas object
26+ console .log (projectDataInstance .getScreen (0 ).getAreas ()) // array of areas object
2327```
2428
2529### Get area
2630
27- Gets area with given ` index ` .
31+ Gets area with given ` index ` for current screen .
2832
2933``` js
30- const firstScreen = projectDataInstance .getScreen (0 )
31-
32- firstScreen .getArea (0 ) // gets area with index 0 (first area)
34+ console .log (projectDataInstance .getScreen (0 ).getArea (0 )) // gets area with index 0 (first area)
3335```
3436
3537### Calculate screen duration
3638
3739Calculates screen duration. It's useful when there is need to manually set screen duration.
3840
3941``` js
40- const screen = projectDataInstance .getScreen (0 )
41-
42- screen .calculateScreenDuration ()
42+ console .log (projectDataInstance .getScreen (0 ).calculateScreenDuration ())
4343```
4444
4545### Get max possible duration
@@ -48,14 +48,12 @@ Filters areas to find only video ones. Checks if count of video areas is more th
4848 Otherwise returns ` maxDuration ` if there is one, or ` duration ` .
4949
5050``` js
51- const screen = projectDataInstance .getScreen (0 )
52-
53- screen .getMaxPossibleDuration ()
51+ console .log (projectDataInstance .getScreen (0 ).getMaxPossibleDuration ())
5452```
5553
5654## Setters
5755
58- All the setters of screen instance can be called with chaining .
56+ All the setters of screen instance can be called in chain .
5957
6058### Set duration
6159
@@ -64,16 +62,11 @@ then also throws error. Otherwise sets given value.
6462
6563``` js
6664Renderforest .getProjectData (15220886 )
67- .then ((projectDataInstance ) => {
68- const screen = projectDataInstance .getScreen (0 )
69- // these steps are not necessary
70- const screenDuration = screen .calculateScreenDuration ()
71- console .log (screenDuration)
72- const maxDuration = screen .getMaxPossibleDuration ()
73- console .log (maxDuration)
74-
75- return screen .setDuration (5 )
76- })
65+ .then ((projectDataInstance ) =>
66+ projectDataInstance .getScreen (0 )
67+ .setDuration (5 )
68+ .save ()
69+ )
7770```
7871
7972### Toggle icon position
@@ -82,12 +75,11 @@ If screen does not have icon adjustment, then throws error. Otherwise toggles ic
8275
8376``` js
8477Renderforest .getProjectData (15220886 )
85- .then ((projectDataInstance ) => {
86- const screen = projectDataInstance .getScreen (0 )
87-
88- return screen .setDuration (5 )
78+ .then ((projectDataInstance ) =>
79+ projectDataInstance .setDuration (5 )
8980 .toggleIconPosition ()
90- })
81+ .save ()
82+ )
9183```
9284
9385[ See screen duration and toggle icon position adjustment example] ( /samples/project-data/screen-duration-and-icon-toggle.js )
@@ -99,17 +91,40 @@ Otherwise sets `start` and `duration` params for lower third settings.
9991
10092``` js
10193Renderforest .getProjectData (15220886 )
102- .then ((projectDataInstance ) => {
103- const screen = projectDataInstance .getScreen (0 )
94+ .then ((projectDataInstance ) =>
95+ projectDataInstance .getScreen (0 )
96+ .setLowerThirdSettings (2 , 5 )
97+ .save ()
98+ )
99+ ```
100+
101+ [ See lower third settings adjustment example] ( /samples/project-data/lower-third-settings.js )
102+
103+ ## Return project data
104104
105- screen
106- . setLowerThirdSettings ( 2 , 5 )
105+ For project data manipulation sometimes there is need to step back from
106+ area object to project data for further development.
107107
108- return projectDataInstance .save ()
109- })
110- .catch (console .error )
108+ ``` js
109+ projectDataInstance .getScreen (0 )
110+ .setLowerThirdSettings (2 , 5 )
111+ .returnProjectData ()
112+ .getScreen (1 )
113+ .setDuration (8 )
111114```
112115
113- [ See lower third settings adjustment example] ( /samples/project-data/lower-third-settings.js )
116+ ## Save
117+
118+ Save method works with the same logic as the project data one.
119+ From the hood it steps back project data then calls save method.
120+
121+ ``` js
122+ projectDataInstance .getScreen (0 )
123+ .setLowerThirdSettings (2 , 5 )
124+ .returnProjectData ()
125+ .getScreen (1 )
126+ .setDuration (8 )
127+ .save ()
128+ ```
114129
115130** [ ⬆ back to the top] ( #screens-api ) **
0 commit comments