Skip to content

Commit

Permalink
feat: Added code to play embedded youtube and vimeo videos
Browse files Browse the repository at this point in the history
Merge pull request #318 from DFE-Digital/mab/embededvideo
  • Loading branch information
MartinBelton-gov authored Nov 8, 2023
2 parents a250eff + cef33b7 commit 2d65c35
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public class VideoResource : IContent
public string Id { get; set; }
public Asset Video { get; set; }
public Document Transcript { get; set; }
public string EmbeddedSourceUrl { get; set; }
}
28 changes: 25 additions & 3 deletions Childrens-Social-Care-CPD/Views/Shared/_VideoResource.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,29 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters">
<video id="videoPlayer" preload="none">
<source src="@Model.Video.File.Url">
</video>
@if(!string.IsNullOrEmpty(Model.EmbeddedSourceUrl))
{
if (@Model.EmbeddedSourceUrl.IndexOf("vimeo") > -1)
{
<iframe width="560" height="315"
title="Vimeo Video"
src="@Model.EmbeddedSourceUrl"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen>
</iframe>
}
else
{
<video name="media" src="@Model.EmbeddedSourceUrl" preload="none"></video>
}
}
else
{
<video id="videoPlayer" name="media" preload="none">
<source src="@Model.Video.File.Url">
</video>
}

<details class="govuk-details govuk-!-margin-top-3" data-module="govuk-details">
<summary class="govuk-details__summary"> <span class="govuk-details__summary-text">View transcript </span></summary>
<div class="govuk-details__text">
Expand All @@ -19,5 +39,7 @@
}
</div>
</details>


</div>
</div>

0 comments on commit 2d65c35

Please sign in to comment.