-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ISSUE #50 - Added autoplay configuration #52
base: 8.x-1.x
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't test it manually, but can you provide test coverage too? You can add the checks for the autoplay in the test \Drupal\Tests\media_avportal\FunctionalJavascript\MediaAvPortalCreateContentTest::testAvPortalVideoMediaEntity()
.
/** | ||
* The default autoplay setting. | ||
*/ | ||
public const DEFAULT_AUTOPLAY = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can skip this constant, it's enough to use a boolean.
@@ -126,6 +131,7 @@ public static function defaultSettings(): array { | |||
return [ | |||
'max_width' => self::DEFAULT_WIDTH, | |||
'max_height' => self::DEFAULT_HEIGHT, | |||
'autoplay_setting' => self::DEFAULT_AUTOPLAY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just use
'autoplay_setting' => self::DEFAULT_AUTOPLAY, | |
'autoplay' => TRUE, |
@@ -234,6 +246,7 @@ public function viewElements(FieldItemListInterface $items, $langcode): array { | |||
protected function viewElement(FieldItemInterface $item): array { | |||
$max_width = $this->getSetting('max_width'); | |||
$max_height = $this->getSetting('max_height'); | |||
$autoplay_setting = $this->getSetting('autoplay_setting') == 0 ? FALSE : TRUE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setting is a boolean, why we compare it with 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see below that autoplay was passed as string true
, maybe we should convert to strings true/false?
@@ -155,6 +161,12 @@ public function settingsForm(array $form, FormStateInterface $form_state): array | |||
'#min' => 0, | |||
]; | |||
|
|||
$form['autoplay_setting'] = [ | |||
'#type' => 'checkbox', | |||
'#title' => $this->t('Autoplay enabled'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'#title' => $this->t('Autoplay enabled'), | |
'#title' => $this->t('Autoplay'), |
should be enough.
OPENEUROPA-[Insert ticket number here]
Description
Autoplay setting has been added in FieldFormatter
Change log
Autoplay setting