Skip to content

Commit

Permalink
Update the media embed options to support localization parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
rdacrodgers committed Jun 23, 2022
1 parent 8374286 commit 94de247
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
22 changes: 17 additions & 5 deletions Brightcove.Web/misc/BrightcovePlayerMarkupGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ protected virtual string GenerateJavascriptEmbed(MediaGenerateMarkupArgs args)
string muted = String.Empty;
string assetId = "";
string showPlaylists = "";
string languageEmbed = "";

// Add autoplay
if (args.Properties.Collection[BrightcovePlayerParameters.EmbedStyle] != null)
Expand Down Expand Up @@ -162,9 +163,14 @@ protected virtual string GenerateJavascriptEmbed(MediaGenerateMarkupArgs args)
showPlaylists = "<ol class='vjs-playlist'></ol>";
}

if(!string.IsNullOrWhiteSpace(args.Language))
{
languageEmbed = $"lang='{args.Language}'";
}

//data-item-id='{args.Properties.ItemId}'
return $@"{responsive}
<video {assetId}
<video {languageEmbed} {assetId}
data-account='{args.AccountItem[BrightcovePlayerParameters.AccountId]}'
data-player='{args.PlayerItem[BrightcovePlayerParameters.PlayerId]}'
data-embed='default'
Expand Down Expand Up @@ -269,10 +275,10 @@ protected virtual Dictionary<string, string> GetPlayerParameters(MediaGenerateMa
}

// Set player id for player
if (args.PlayerItem != null && !args.PlayerItem[FieldIDs.Player.Id].IsNullOrEmpty())
if (args.PlayerItem != null && !args.PlayerItem["ID"].IsNullOrEmpty())
{
dictionary["data-player"] = args.PlayerItem[FieldIDs.Player.Id];
scriptUrl = scriptUrl.Replace(PlayerToken, args.PlayerItem[FieldIDs.Player.Id]);
dictionary["data-player"] = args.PlayerItem["ID"].ToString();
scriptUrl = scriptUrl.Replace(PlayerToken, args.PlayerItem["ID"].ToString());
}

// Set account id for player
Expand All @@ -294,6 +300,12 @@ protected virtual Dictionary<string, string> GetPlayerParameters(MediaGenerateMa
dictionary["data-playlist-id"] = args.MediaItem[FieldIDs.MediaElement.Id];
}
}

if(!string.IsNullOrWhiteSpace(args.Language))
{
dictionary["lang"] = args.Language;
}

//add cms version
/*string sitecoreVersion = About.Version;
string connectorVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
Expand All @@ -307,7 +319,7 @@ private void AddPlayerScriptUrl(PlayerMarkupResult playerMarkupResult, MediaGene
if (args.AccountItem != null && args.PlayerItem != null)
{
var publisherId = args.AccountItem[FieldIDs.Account.AccountId];
var playerId = args.PlayerItem[FieldIDs.Player.Id];
var playerId = args.PlayerItem["ID"];

if (!publisherId.IsNullOrEmpty() && !playerId.IsNullOrEmpty())
{
Expand Down
7 changes: 5 additions & 2 deletions Brightcove.Web/misc/EmbedAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public class EmbedAsset : WizardForm

protected Combobox PlayersList;

protected ID SourceItemID
protected Edit AssetLanguage;

protected ID SourceItemID
{
get
{
Expand Down Expand Up @@ -282,7 +284,8 @@ protected virtual void InsertMedia(PlayerProperties playerProperties)
MarkupType = MarkupType.Frame,
Properties = playerProperties,
MediaItem = Sitecore.Context.ContentDatabase.GetItem(SourceItemID),
PlayerItem = Sitecore.Context.ContentDatabase.GetItem(playerProperties.PlayerId)
PlayerItem = Sitecore.Context.ContentDatabase.GetItem(playerProperties.PlayerId),
Language = AssetLanguage.Value
};

args.AccountItem = Sitecore.Context.ContentDatabase.GetItem(string.Join("/", args.MediaItem.Paths.Path.Split('/').Take(5)));
Expand Down
3 changes: 2 additions & 1 deletion Brightcove.Web/misc/EmbedMediaController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public ActionResult RenderVideo()
MarkupType = MarkupType.Html,
Properties = properties,
MediaItem = Sitecore.Context.Database.GetItem(properties.ItemId),
PlayerItem = Sitecore.Context.Database.GetItem(properties.PlayerId)
PlayerItem = Sitecore.Context.Database.GetItem(properties.PlayerId),
Language = rendering.Parameters["Lang"]
};

args.Properties.Template = args.MediaItem.Template.ID;
Expand Down
2 changes: 2 additions & 0 deletions Brightcove.Web/misc/MediaGenerateMarkupArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ public MediaGenerateMarkupArgs()
/// Gets or sets the markup.
/// </summary>
public PlayerMarkupResult Result { get; set; }

public string Language { get; set; } = "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@
<Border Padding="5px 4px 5px 5px" Width="150px">
<Edit ID="HeightInput" Width="75px" Value="300" Type="number"/>
</Border>
<Border Padding="0px 4px 0px 5px" Width="150px">
<Literal Text="Language:" Width="100px"/>
</Border>
<Border Padding="5px 4px 5px 5px" Width="150px">
<Edit ID="AssetLanguage" Width="75px" Value="" Type="text"/>
</Border>
</GridPanel>
<Edit ID="EmbedInput" Type="Hidden" Value="" />
<Edit ID="SizingInput" Type="Hidden" Value="" />
Expand Down

0 comments on commit 94de247

Please sign in to comment.