@@ -1315,9 +1315,6 @@ public function toXlf()
13151315 // merge regions and drawers into one array and go through it.
13161316 $ allRegions = array_merge ($ this ->regions , $ this ->drawers );
13171317
1318- // Used to identify Layouts which only have Canvas with global elements
1319- $ isCanvasOnlyRegion = true ;
1320-
13211318 foreach ($ allRegions as $ region ) {
13221319 /* @var Region $region */
13231320
@@ -1379,8 +1376,7 @@ public function toXlf()
13791376 // Pull out the global widget, if we have one (we should)
13801377 if ($ item ->type === 'global ' ) {
13811378 $ widget = $ item ;
1382- } else {
1383- $ isCanvasOnlyRegion = false ;
1379+
13841380 }
13851381
13861382 // Get the highest duration.
@@ -1403,8 +1399,6 @@ public function toXlf()
14031399 $ widgets = [$ widget ];
14041400 }
14051401 } else {
1406- $ isCanvasOnlyRegion = false ;
1407-
14081402 $ widgets = $ region ->getPlaylist ()->setModuleFactory ($ this ->moduleFactory )->expandWidgets ();
14091403 }
14101404
@@ -1419,6 +1413,8 @@ public function toXlf()
14191413 }
14201414
14211415 // Work out if we have any "lead regions", those are Widgets with a duration
1416+ $ maxWidgetDurationInLayout = 1 ;
1417+
14221418 foreach ($ widgets as $ widget ) {
14231419 if (($ widget ->useDuration == 1 && $ widget ->type !== 'global ' )
14241420 || $ countWidgets > 1
@@ -1427,6 +1423,11 @@ public function toXlf()
14271423 ) {
14281424 $ layoutCountRegionsWithDuration ++;
14291425 }
1426+
1427+ $ maxWidgetDurationInLayout = Max (
1428+ ($ widget ->useDuration == 1 ? $ widget ->duration : $ widget ->calculatedDuration ),
1429+ $ maxWidgetDurationInLayout
1430+ );
14301431 }
14311432
14321433 foreach ($ widgets as $ widget ) {
@@ -1454,16 +1455,10 @@ public function toXlf()
14541455 ) {
14551456 // Make sure this Widget expires immediately so that the other Regions can be the leaders when
14561457 // it comes to expiring the Layout
1457- $ widgetDuration = Widget::$ widgetMinDuration ;
1458- }
1459-
1460- // Layouts which only have Canvas with global elements
1461- if ($ region ->type == 'canvas '
1462- && $ widget ->type == 'global '
1463- && $ isCanvasOnlyRegion
1464- ) {
1465- $ widget ->calculatedDuration = 10 ;
1466- $ widgetDuration = $ widget ->calculatedDuration ;
1458+ // Only do this when the widget's default duration is not the max duration in layout
1459+ if ($ widgetDuration < $ maxWidgetDurationInLayout ) {
1460+ $ widgetDuration = Widget::$ widgetMinDuration ;
1461+ }
14671462 }
14681463
14691464 if ($ region ->isDrawer === 0 ) {
@@ -1477,7 +1472,7 @@ public function toXlf()
14771472 if ($ tempCyclePlaybackAverageDuration ) {
14781473 $ region ->duration = $ region ->duration + $ tempCyclePlaybackAverageDuration ;
14791474 } else {
1480- $ region ->duration = $ region ->duration + $ widget -> calculatedDuration ;
1475+ $ region ->duration = $ region ->duration + $ widgetDuration ;
14811476 }
14821477
14831478 // We also want to add any transition OUT duration
@@ -1516,6 +1511,7 @@ public function toXlf()
15161511 ($ widget ->type === 'video ' || $ widget ->type === 'audio ' )
15171512 && $ widget ->useDuration === 0
15181513 );
1514+
15191515 $ mediaNode ->setAttribute ('duration ' , ($ isEndDetectVideoWidget ? 0 : $ widgetDuration ));
15201516 $ mediaNode ->setAttribute ('useDuration ' , $ widget ->useDuration );
15211517 $ widgetActionNode = null ;
0 commit comments