Skip to content
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

Open
wants to merge 1 commit into
base: 8.x-1.x
Choose a base branch
from

Conversation

pgrandeg
Copy link

OPENEUROPA-[Insert ticket number here]

Description

Autoplay setting has been added in FieldFormatter

Change log

  • Added:
    Autoplay setting

Copy link
Contributor

@brummbar brummbar left a 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;
Copy link
Contributor

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just use

Suggested change
'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;
Copy link
Contributor

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?

Copy link
Contributor

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'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'#title' => $this->t('Autoplay enabled'),
'#title' => $this->t('Autoplay'),

should be enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants