Skip to content

Commit

Permalink
DreamBroker autoplay
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed May 12, 2020
1 parent 4c6ed4a commit 8532caa
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
angular.module("umbraco").controller("Skybrud.VideoPicker.DreamBroker.Config.Controller", function ($scope, formHelper) {

var config = $scope.model.config;

function bool(alias, value) {

if (config[alias]) return;

config[alias] = {
readonly: true,
value: value
};

}

bool("consent", false);
bool("autoplay", false);

$scope.properties = [
{
alias: "consent",
label: "Require consent",
description: "Select whether the embed code requires prior consent before being shown to the user.",
value: config.consent.value,
view: "boolean"
},
{
alias: "autoplay",
label: "Autoplay",
description: "Select whether the video should automatically start to play when the player loads.",
value: config.autoplay.value,
view: "boolean"
}
];

$scope.save = function () {

if (formHelper.submitForm({ scope: $scope })) {

formHelper.resetForm({ scope: $scope });

$scope.properties.forEach(function (p) {

// Fix boolean values (instead of "1" and "0")
if (p.view === "boolean") {
p.value = p.value === "1" || p.value === true;
}

config[p.alias] = {
readonly: true,
value: p.value
};

});

$scope.model.submit(config);

}

};

});
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{
alias: "consent",
label: "Require consent",
description: "Sets whether the embed code requires prior consent before being shown to the user.",
description: "Select whether the embed code requires prior consent before being shown to the user.",
value: config.consent.value,
view: "boolean"
//view: "/App_Plugins/Skybrud.VideoPicker/Views/Editors/ConfigOption.html",
Expand All @@ -34,28 +34,28 @@
{
alias: "nocookie",
label: "No cookies",
description: "Sets whether the player should use YouTube's <c>www.youtube-nocookie.com</c> domain instead.",
description: "Select whether the player should use YouTube's <c>www.youtube-nocookie.com</c> domain instead.",
value: config.nocookie.value,
view: "boolean"
},
{
alias: "controls",
label: "Show controls",
description: "Sets whether player controls should be displayed in the video player.",
description: "Select whether player controls should be displayed in the video player.",
value: config.controls.value,
view: "boolean"
},
{
alias: "autoplay",
label: "Autoplay",
description: "Sets whether the video should automatically start to play when the player loads.",
description: "Select whether the video should automatically start to play when the player loads.",
value: config.autoplay.value,
view: "boolean"
},
{
alias: "loop",
label: "Loop",
description: "Sets whether the video should play again and again.",
description: "Select whether the video should play again and again.",
value: config.loop.value,
view: "boolean"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<div ng-controller="Skybrud.VideoPicker.DreamBroker.Config.Controller">

<form name="dreambrokerConfig" ng-submit="save()" novalidate val-form-manager>

<umb-editor-view>

<umb-editor-header
name="model.title"
hide-icon="true"
hide-alias="true"
name-locked="true"
hide-description="true">
</umb-editor-header>

<umb-editor-container>
<umb-box>
<umb-box-content>
<umb-property property="property" ng-repeat="property in properties">
<umb-property-editor model="property"></umb-property-editor>
</umb-property>
</umb-box-content>
</umb-box>
</umb-editor-container>

<umb-editor-footer>
<umb-editor-footer-content-right>
<umb-button
type="button"
button-style="link"
label-key="general_close"
action="model.close()">
</umb-button>
<umb-button
type="submit"
button-style="success"
label-key="general_submit">
</umb-button>
</umb-editor-footer-content-right>
</umb-editor-footer>

</umb-editor-view>

</form>

</div>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"/App_Plugins/Skybrud.VideoPicker/Scripts/Controllers/VideoProviders.js",
"/App_Plugins/Skybrud.VideoPicker/Scripts/Controllers/VideoPreview.js",
"/App_Plugins/Skybrud.VideoPicker/Scripts/Controllers/Providers/Config.js",
"/App_Plugins/Skybrud.VideoPicker/Scripts/Controllers/Providers/DreamBroker/Config.js",
"/App_Plugins/Skybrud.VideoPicker/Scripts/Controllers/Providers/Vimeo/Config.js",
"/App_Plugins/Skybrud.VideoPicker/Scripts/Controllers/Providers/YouTube/Config.js"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ public class DreamBrokerDataTypeConfig : IProviderDataTypeConfig {
[JsonProperty("consent")]
public DataTypeConfigOption<bool> RequireConsent { get; }

[JsonProperty("autoplay")]
public DataTypeConfigOption<bool> Autoplay { get; }

public DreamBrokerDataTypeConfig() {
IsEnabled = false;
RequireConsent = new DataTypeConfigOption<bool>(false);
Autoplay = new DataTypeConfigOption<bool>(false);
}

public DreamBrokerDataTypeConfig(JObject value) {
IsEnabled = value.GetBoolean("enabled");
RequireConsent = new DataTypeConfigOption<bool>(value.GetBoolean("consent.value"));
Autoplay = new DataTypeConfigOption<bool>(value.GetBoolean("autoplay.value"));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public DreamBrokerEmbedOptions(DreamBrokerVideoDetails details, DreamBrokerDataT
config = config ?? new DreamBrokerDataTypeConfig();

RequireConsent = config.RequireConsent.Value;
Autoplay = config.Autoplay.Value;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class DreamBrokerVideoProvider : IVideoProvider {

public string Name => "Dream Broker";

public string ConfigView => "/App_Plugins/Skybrud.VideoPicker/Views/DefaultProvider/Config.html";
public string ConfigView => "/App_Plugins/Skybrud.VideoPicker/Views/DreamBroker/Config.html";

public string EmbedView => null;//"/App_Plugins/Skybrud.VideoPicker/Views/DefaultProvider/Embed.html";

Expand Down

0 comments on commit 8532caa

Please sign in to comment.