diff --git a/app/assets/images/locked-media-poster.svg b/app/assets/images/locked-media-poster.svg new file mode 100644 index 000000000..f1d6e6b9c --- /dev/null +++ b/app/assets/images/locked-media-poster.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/assets/stylesheets/media.scss b/app/assets/stylesheets/media.scss index 2bffc7b9b..cd4cfb373 100644 --- a/app/assets/stylesheets/media.scss +++ b/app/assets/stylesheets/media.scss @@ -306,6 +306,14 @@ width: 100%; } } + + .locked-media { + width: 100vw; + max-height: calc(100vh - 98px); + img { + height: 100%; + } + } } .authLinkWrapper { diff --git a/app/components/embed/media_with_companion_windows_component.html.erb b/app/components/embed/media_with_companion_windows_component.html.erb index 5dcb6340b..d8a2cc2ff 100644 --- a/app/components/embed/media_with_companion_windows_component.html.erb +++ b/app/components/embed/media_with_companion_windows_component.html.erb @@ -88,6 +88,12 @@
+
+ + <%= image_tag 'locked-media-poster.svg', loading: 'lazy' %> + +
+ <%= render Embed::MediaTagComponent.with_collection(resources_with_primary_file, include_transcripts:, druid:, diff --git a/app/javascript/src/controllers/locked_media_poster_controller.js b/app/javascript/src/controllers/locked_media_poster_controller.js new file mode 100644 index 000000000..6b0dc8d2b --- /dev/null +++ b/app/javascript/src/controllers/locked_media_poster_controller.js @@ -0,0 +1,18 @@ +import { Controller } from "@hotwired/stimulus" + +export default class extends Controller { + // Display the lock if the video tag doesn't have a poster + show() { + if (!this.hasPoster()) + this.element.style.display = 'flex' + } + + hide() { + this.element.style.display = 'none' + } + + hasPoster() { + const tags = document.querySelectorAll('video,audio') + return [...tags].some((tag) => tag.getAttribute('poster')) + } +} \ No newline at end of file